3 ms·
> let* permits expressions on the right refer to arbitrary other symbols bound by the let* In what language? I just checked Elisp, SBCL, and Guile, and they al
by amake 3y ago
> let* permits expressions on the right refer to arbitrary other symbols bound by the let*
In what language? I just checked Elisp, SBCL, and Guile, and they all error out if you refer to a variable not previously defined by a left-to-right traversal of the varlist:
(let* ((a (+ b 1)) (b 1)) a)
Edit: This doesn't work either:
(let* ((a (lambda () (+ b 1))) (b 1)) (funcall a)) ; (funcall a) -> (a) for Schemes
- amake 3y agoAnyway, as far as I'm seeing it's perfectly possible to implement let* consistent with the above behavior as a macro without mutation as such: (define-macro (let* bindings &rest body) (if (null? bindings) `(progn ,@body) `(let (,(car bindings)) (let* ,(cdr bindings) ,@body))))