> For the complete documentation index, see [llms.txt](https://primer.interlisp.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://primer.interlisp.org/variable-bindings-and-scope.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
