masak / bel

An interpreter for Bel, Paul Graham's Lisp language
GNU General Public License v3.0
25 stars 1 forks source link

Add these as tests to mac-catch.t #430

Open masak opened 1 year ago

masak commented 1 year ago
$ perl -Ilib bin/bel
Language::Bel 0.58 -- msys.
> (catch (throw 'hah))
hah
> (catch (bind break (fn () (throw 'break)) (break)))
break

These have the expected semantics, but I just noticed that the test file for catch is extremely sparse.

Maybe this one too:

$ perl -Ilib bin/bel
Language::Bel 0.58 -- msys.
> (mac each/b (var expr . body) `(catch (bind break (fn () (throw 'break)) (map (fn (,var) ,@body) ,expr))))
> (each/b x '(1 2 3 4 5) (pr x \lf) (if (> x 3) (break)))
1
2
3
4
break
>
masak commented 1 year ago

And maybe one that does effectively a tree traversal, but breaks out of it early, returning the result-so-far.