rubymotionlisp 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubylisp/builtins.rb +7 -0
- data/lib/rubylisp/cons_cell.rb +1 -0
- data/lib/rubylisp/prim_special_forms.rb +35 -2
- data/lib/rubymotion/debug.rb +25 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dda4c6e2e0b9e98084434161a3c0442542e51e6c
|
4
|
+
data.tar.gz: 321a515ebc17e84c7c29fca9f479d87a9b9c253d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d55fb467b861a95fd5d99fd97e67e74a92e4ad39f67625679487d433f3bf475effcafc293ac9d920ac5c5141d823d8e0effbe4295c9e8e8e4e525944638c6079
|
7
|
+
data.tar.gz: 75dd34314faf4e762c90805402cf530cdbce9902d1e28bb42931342a3d5e66eee359ed0d453037811f848d0c3d4110a8a893ab78daa43822c4905e3ef3503a2a
|
data/lib/rubylisp/builtins.rb
CHANGED
data/lib/rubylisp/cons_cell.rb
CHANGED
@@ -348,9 +348,9 @@ module Lisp
|
|
348
348
|
end
|
349
349
|
|
350
350
|
|
351
|
-
def self.
|
351
|
+
def self.common_let_impl(args, env)
|
352
352
|
bindings = args.car || Lisp::ConsCell.new
|
353
|
-
return Lisp::Debug.process_error("let requires a list of bindings as it's
|
353
|
+
return Lisp::Debug.process_error("let requires a list of bindings as it's first argument", env) unless bindings.list?
|
354
354
|
local_frame = EnvironmentFrame.extending(env, "let")
|
355
355
|
local_frame.previous = env
|
356
356
|
do_let_bindings(bindings, env, local_frame)
|
@@ -358,6 +358,39 @@ module Lisp
|
|
358
358
|
end
|
359
359
|
|
360
360
|
|
361
|
+
def self.named_let_impl(args, env)
|
362
|
+
name = args.car
|
363
|
+
bindings = args.cadr || Lisp::ConsCell.new
|
364
|
+
binding_names = bindings.to_a.map {|b| b.car}
|
365
|
+
return Lisp::Debug.process_error("named let requires a list of bindings as it's second argument", env) unless bindings.list?
|
366
|
+
body = args.cddr
|
367
|
+
local_frame = EnvironmentFrame.extending(env, "let-#{name.to_s}")
|
368
|
+
local_frame.previous = env
|
369
|
+
do_let_bindings(bindings, env, local_frame)
|
370
|
+
Lisp.named_let_stack.push(name)
|
371
|
+
while true
|
372
|
+
new_values = catch :named_let_application do
|
373
|
+
result = body.evaluate_each(local_frame)
|
374
|
+
Lisp.named_let_stack.pop
|
375
|
+
return result
|
376
|
+
end
|
377
|
+
return Lisp::Debug.process_error("named let call requires the same number of values as bindings", env) unless binding_names.length == new_values.length
|
378
|
+
binding_names.zip(new_values) do |binding_pair|
|
379
|
+
local_frame.bind_locally(binding_pair[0], binding_pair[1])
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
|
385
|
+
def self.let_impl(args, env)
|
386
|
+
if args.car.symbol?
|
387
|
+
named_let_impl(args, env)
|
388
|
+
else
|
389
|
+
common_let_impl(args, env)
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
|
361
394
|
def self.letstar_impl(args, env)
|
362
395
|
bindings = args.car || Lisp::ConsCell.new
|
363
396
|
return Lisp::Debug.process_error("let requires a list of bindings as it's firest argument", env) unless bindings.list?
|
data/lib/rubymotion/debug.rb
CHANGED
@@ -28,13 +28,37 @@ module Lisp
|
|
28
28
|
end
|
29
29
|
|
30
30
|
|
31
|
+
# def self.log_eval(sexpr, env)
|
32
|
+
# end
|
33
|
+
|
34
|
+
|
35
|
+
# def self.log_result(result, env)
|
36
|
+
# end
|
37
|
+
|
38
|
+
def self.print_dashes(level)
|
39
|
+
NSLog("-" * level)
|
40
|
+
end
|
41
|
+
|
42
|
+
|
31
43
|
def self.log_eval(sexpr, env)
|
44
|
+
if !self.eval_in_debug_repl && self.trace
|
45
|
+
depth = env.depth
|
46
|
+
NSLog("% #d: " % depth)
|
47
|
+
print_dashes(depth)
|
48
|
+
NSLog("> #{sexpr.to_s}")
|
49
|
+
end
|
32
50
|
end
|
33
51
|
|
34
52
|
|
35
53
|
def self.log_result(result, env)
|
54
|
+
if !self.eval_in_debug_repl && self.trace
|
55
|
+
depth = env.depth
|
56
|
+
NSLog("% #d: <" % depth)
|
57
|
+
print_dashes(depth)
|
58
|
+
NSLog(" #{result.to_s}")
|
59
|
+
end
|
36
60
|
end
|
37
|
-
|
61
|
+
|
38
62
|
|
39
63
|
end
|
40
64
|
end
|