Difference between LET and LET* in Common LISP
LET
Parallel binding which means the bindings come to life at the same time and they do not shadow each other. The values are effective inside LET and they are undefined outside LET. Just like local variables.
LET binds variables all at the same time.
None of the variables defined in the LET have a value after lisp has finished evaluating the form.
Example 1:
Input:
* (setf x 'outside)
* (let ((x 'inside)
(y x))
(list x y))
Output:
(INSIDE OUTSIDE)
Example 2:
Input:
(let ((a 3)
(b 4)
(c 5))
(* (+ a b)c))
Output:
35
Example 3:
Input:
(setq a 10)
(let ((a 3)
(m a))
(+m a))
Output:
13
LET*
Sequential binding.
Example:
Input:
* (setf x 'outside)
* (let* ((x 'inside)
(y x))
(list x y))
Output:
(INSIDE INSIDE)
It always more efficient to use LET than LET*. Since the program can run parallel when using LET.