tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit ee593db8f702acefb60ae34e95e29f0eda151bd4
parent 67c4ee735b211527ec89a29a86b3e73b3019ca23
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Thu, 19 Dec 2019 20:00:36 -0800

Reimplement let enabling recursion inside bindings

Makes let behave like letrec in other lisps. This comes with minor
performance costs but simplifies the code and allows for all use cases
without having to choice between let, let*, letrec, similar to haskell.

tibs/lib.tsp | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tibs/lib.tsp b/tibs/lib.tsp @@ -71,7 +71,13 @@ (defmacro (unless con . body) (list 'cond (list (list not con) (cons 'do body)))) (defmacro (let vars . body) - (cons (list* 'lambda (map car vars) body) (map cadr vars))) + (list (list* 'lambda () + (append + (map + (lambda (x) + (list 'define (car x) (cadr x))) + vars) + body)))) (defmacro (recur fn vars . body) (list* (list* 'lambda (cons fn (map car vars)) body) (list* 'lambda (map car vars) body)