Can anyone explain the difference simply? I don\'t think I understand the concept from the textbooks/sites I have consulted.
If you use let
, you can't reference other bindings which appear in the same let
expression.
For example, this won't work:
(let ((x 10)
(y (+ x 6))) ; error! unbound identifier: x
y)
But if you use let*
, it is possible to refer to previous bindings which appear in the same let*
expression:
(let* ((x 10)
(y (+ x 6))) ; works fine
y)
=> 16
It's all here in the documentation.