git @ Cat's Eye Technologies Robin / 1bd053a
Remove tests that just repeat code in the supplied modules. catseye 13 years ago
2 changed file(s) with 0 addition(s) and 90 deletion(s). Raw diff Collapse all Expand all
2626 | x))))
2727 ? robin: uncaught exception: (unbound-identifier . x)
2828
29 `unbind` could be implemented in Robin.
30
31 | (robin (0 . 1) (small (0 . 1) env (0 . 1))
32 | ((bind del-env
33 | (fun (self name env)
34 | (if (equal? env (literal ()))
35 | env
36 | (if (equal? name (head (head env)))
37 | (self self name (tail env))
38 | (pair (head env) (self self name (tail env))))))
39 | (macro (self args env)
40 | (eval (del-env del-env (head args) env) (head (tail args)))))
41 | if (if #t (literal x) (literal y))))
42 ? robin: uncaught exception: (unbound-identifier . if)
43
4429 ### `sandbox` ###
4530
4631 `sandbox` takes a list of symbols as its first argument, and evaluates its
5843 ? robin: uncaught exception: (unbound-identifier . head)
5944
6045 Could be useful to prevent some bindings from being exported from a module.
61
62 `sandbox` could be implemented in Robin.
63
64 | (robin (0 . 1) (small (0 . 1) env (0 . 1))
65 | ((bind elem
66 | (fun (self x xs)
67 | (if (equal? xs ())
68 | #f
69 | (if (equal? x (head xs))
70 | #t
71 | (self self x (tail xs)))))
72 | (bind keep-env
73 | (fun (self names env)
74 | (if (equal? env ())
75 | env
76 | (if (elem elem (head (head env)) names)
77 | (pair (head env) (self self names (tail env)))
78 | (self self names (tail env)))))
79 | (macro (self args env)
80 | (eval (keep-env keep-env (head args) env) (head (tail args))))))
81 | (pair tail)
82 | (head (pair 8 9))))
83 ? robin: uncaught exception: (unbound-identifier . head)
4444 | (robin (0 . 1) (small (0 . 1))
4545 | (literal (hello world)))
4646 = (hello world)
47
48 `literal` could be implemented in Robin.
49
50 | (robin (0 . 1) (small (0 . 1))
51 | ((macro (self args env) (head args)) hello))
52 = hello
5347
5448 `literal` is basically equivalent to Scheme's `quote`.
5549
9791 | (b (fun (a) (pair a a))))
9892 | (b 7)))
9993 = (7 . 7)
100
101 Functions can be implemented in Robin, using macros, but the implementation
102 is rather onerous, so the details are omitted here.
10394
10495 `fun` is basically equivalent to Scheme's `lambda`.
10596
138129 | (find find (literal ((c . d) (e . f) (a . b))) (literal a))))
139130 = (a . b)
140131
141 `bind` could be implemented in Robin.
142
143 | (robin (0 . 1) (small (0 . 1))
144 | ((macro (self args env) (eval
145 | (pair (pair (head args) (eval env (head (tail args)))) env)
146 | (head (tail (tail args)))))
147 | x (literal hello) (pair x x)))
148 = (hello . hello)
149
150132 `bind` is basically equivalent to Scheme's `let`, but only one
151133 binding may be given.
152134
199181 | (robin (0 . 1) (small (0 . 1))
200182 | (let () (literal hi)))
201183 = hi
202
203 `let` could be implemented as a recursive macro in Robin.
204
205 | (robin (0 . 1) (small (0 . 1))
206 | ((macro (self args env)
207 | (bind bindings (head args)
208 | (if (equal? bindings ())
209 | (eval env (head (tail args)))
210 | (bind binding (head bindings)
211 | (bind name (head binding)
212 | (bind value (eval env (head (tail binding)))
213 | (bind newenv (pair (pair name value) env)
214 | (bind newbindings (tail bindings)
215 | (bind newargs (pair newbindings (tail args))
216 | (eval newenv (pair self newargs)))))))))))
217 | ((a (literal b)) (c #f)) (pair a c)))
218 = (b . #f)
219
220 Bindings internal to the recursive macro don't leak.
221
222 | (robin (0 . 1) (small (0 . 1))
223 | ((macro (self args env)
224 | (bind bindings (head args)
225 | (if (equal? bindings ())
226 | (eval env (head (tail args)))
227 | (bind binding (head bindings)
228 | (bind name (head binding)
229 | (bind value (eval env (head (tail binding)))
230 | (bind newenv (pair (pair name value) env)
231 | (bind newbindings (tail bindings)
232 | (bind newargs (pair newbindings (tail args))
233 | (eval newenv (pair self newargs)))))))))))
234 | ((a (literal b)) (c #f)) newbindings))
235 ? robin: uncaught exception: (unbound-identifier . newbindings)
236184
237185 `let` is basically equivalent to Scheme's `let*` or Haskell's `let`.
238186