Re:Compiling a Lisp to x86-64: Let expressions
by _emacsomancer_ on Thursday October 01, 2020 @10:02PM
(#24658039)
> Well, you've implemented let* :
(let* ((a 1) (b a)) (+ a b))
I think this should just be plain let.If I do:
(define-syntax let-
(syntax-rules ()
[(_ ((x e) ...) b1 b2 ...)
((lambda (x ...) b1 b2 ...) e ...)]))
And then try: (let- ((a 2) (b a)) (+ a b))
I get: ; a: undefined;
; cannot reference an identifier before its definition
; in module: top-level
Re:Compiling a Lisp to x86-64: Let expressions
by bjoli on Friday October 02, 2020 @07:28AM
(#24661481)
I don't really understand if you are surprised by that or not. That is the expected behaviour of regular let. Parallel binding. let* is sequential.
Re:Compiling a Lisp to x86-64: Let expressions
by _emacsomancer_ on Friday October 02, 2020 @11:07AM
(#24663398)
I'm not surprised by that. The parent suggested (or I thought that they did) that this was actually the definition for let* . And my point was to show that it does not behave like let* but rather like plain let.
I personally prefer to have 'letrec' as a primitive and implement non-recursive 'let' on top of it by checking whether any newly bound names are referenced from the bound values.