Special Form Entry: SETQ
← Prev | ↑ Chapter | Next → | Index | Symbols
Special Form Entry: SETQ
Name
setq
Class
Special Form
Syntax
(setq sym expr [sym expr] ...)
Arguments and Values
sym: a symbol; not evaluatedexpr: an expression
Description
Assigns values to variables.
Evaluation Rules
- symbols are taken literally
- expressions are evaluated left to right
- assignments occur left to right
Return Values
Returns the value of the last expr.
Side Effects
Establishes or changes variable bindings. Writes the supplied value into the symbol's single binding cell (see chapter 7, "Single-Cell Symbol Binding"); a previous defun on the same symbol is therefore overwritten.
Exceptional Situations
Malformed syntax or invalid assignment targets are erroneous.
Examples
(setq A 10) => 10(setq A 1 B 2) => 2(defun foo (x) x) (setq foo 42)—fooevaluates to42;(foo 5)then signals no function definition.
Compatibility
Stable across vendors.
Notes
set differs by evaluating the symbol designator. AutoLISP is Lisp-1: setq and defun share the same per-symbol binding cell; the most recent write wins (chapter 7).
Availability
- AutoCAD 2026: documented (per Autodesk reference page).
- BricsCAD V26: presumed compatible (no contradicting page found).
- Status: AutoCAD documented; BricsCAD presumed-both pending Phase 4 verification.
Source Notes
- [setq (AutoLISP)](https://help.autodesk.com/cloudhelp/2026/FRA/AutoCAD-LT-AutoLISP-Reference/files/GUID-2F4B7A7B-7B6F-4E1C-B32E-677506094EAA.htm)
- Status: documented.