In Interlisp, SETQ creates a persistent or global binding that keeps its value across computations. In contrast, LET and LET* create temporary, local variables that exist only within the current expression or function. LET evaluates and binds all variables in parallel, so none of them can refer to another defined in the same form. LET*, however, binds variables one at a time in sequence, allowing each new variable to use the values of those bound earlier, making it useful for stepwise calculations or dependent local values.
Form
SETQ
Scope
Global Binding
Example
(SETQ TEMP1 (IPLUS 5 5))
(SETQ RESULT (ITIMES 2 TEMP1))
(SETQ GLOBAL.VALUE TEMP1)
RESULT
Comments by Line Number
1. Global assignment: TEMP1 is now 10.
2. Global assignment: RESULT is now 20.
3. Global assignment: GLOBAL.VALUE is now 10.
4. Returns the current value of RESULT (20).
Form
LET
Scope
Local, Parallel Binding
Example
(LET ((TEMP1 (IPLUS 5 5))
(RESULT 20))
(SETQ GLOBAL.VALUE TEMP1)
(ITIMES RESULT 2))
Comments by Line Number
Local bindings: TEMP1 = 10
RESULT = 20 (Evaluated in parallel. Cannot use TEMP1 here.)