# Variable Bindings and Scope

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.

<table data-card-size="large" data-view="cards"><thead><tr><th>Form</th><th>Scope</th><th>Example</th><th>Comments by Line Number</th></tr></thead><tbody><tr><td>SETQ</td><td>Global Binding</td><td><ol><li><code>(SETQ TEMP1 (IPLUS 5 5))</code></li><li><code>(SETQ RESULT (ITIMES 2 TEMP1))</code></li><li><code>(SETQ GLOBAL.VALUE TEMP1)</code></li><li><br><br><br><code>RESULT</code></li></ol></td><td>1. Global assignment: <code>TEMP1</code> is now 10.<br>2. Global assignment: <code>RESULT</code> is now 20.<br>3. Global assignment: <code>GLOBAL.VALUE</code> is now 10.<br>4. Returns the current value of <code>RESULT</code> (20).</td></tr><tr><td>LET</td><td>Local, Parallel Binding</td><td><ol><li><code>(LET ((TEMP1 (IPLUS 5 5))</code></li><li><code>(RESULT 20))</code></li><li><code>(SETQ GLOBAL.VALUE TEMP1)</code><br></li><li><br><br><code>(ITIMES RESULT 2))</code></li></ol></td><td><ol><li>Local bindings: <code>TEMP1 = 10</code></li><li><code>RESULT = 20</code> (Evaluated in parallel. Cannot use TEMP1 here.)</li><li>Global value of <code>GLOBAL.VALUE</code> set to 10.</li><li>Returns <code>(ITIMES RESULT 2)</code> = 40.</li></ol></td></tr><tr><td>LET*</td><td>Local, Sequential Binding</td><td><ol><li><code>(LET* ((TEMP1 (IPLUS 5 5))</code></li><li><code>(RESULT (ITIMES 2 TEMP1)))</code></li><li><code>(SETQ GLOBAL.VALUE TEMP1)</code></li><li><br><br><br><code>RESULT)</code></li></ol></td><td><ol><li>Local binding: <code>TEMP1 = 10</code> </li><li><code>RESULT = (ITIMES 2 TEMP1)</code> = 20</li><li>Global value of <code>GLOBAL.VALUE</code> set to 10.</li><li>Returns local <code>RESULT</code> = 20.</li></ol></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://primer.interlisp.org/variable-bindings-and-scope.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
