Special Form Entry: COND
← Prev | ↑ Chapter | Next → | Index | Symbols
Special Form Entry: COND
Name
cond
Class
Special Form
Syntax
(cond [(test result ...) ...])
Arguments and Values
- each clause contains a test and zero or more result forms
Description
Sequentially selects the first successful clause.
Evaluation Rules
- tests are evaluated in order
- when a test yields non-nil:
- if result forms exist, they are evaluated sequentially and the last value is returned
- otherwise the test value itself is returned
Return Values
- the selected clause value
- nil if no clause succeeds
Side Effects
Side effects arise from:
- evaluation of each test expression up to and including the first successful one,
- evaluation of the result forms of the selected clause, if any.
No later clause is evaluated after a successful clause is found.
Exceptional Situations
Malformed clause structure is erroneous. An empty clause () signals an
error on both vendors; the message differs (AutoCAD 2022: "syntax error",
localised; BricsCAD V26: "bad argument type <NIL> ; expected <LIST> at
[cond]").
Examples
(cond ((> 2 1) 'YES) (T 'NO)) => YES(cond ((= 1 1))) => T– a clause with no result form returns its test value(cond (42)) => 42(cond (nil) ('ok)) => OK(cond ((setq x 5))) => 5(cond (nil)) => nil,(cond) => nil(cond () (33))– error (empty clause)
Compatibility
Stable across vendors.
Notes
T may be used in the last clause as an always-true test.
Availability
- AutoCAD 2026: documented (per Autodesk reference page).
- BricsCAD V26: compatible.
- Status: verified on both – probes/sources/probe-cond.lsp, every example above identical on AutoCAD 2022 (job 16921381038) and BricsCAD V26 (job 16921381039), 2026-10-04 (autolisp-spec-questions).
Source Notes
- [cond (AutoLISP)](https://help.autodesk.com/cloudhelp/2018/ENU/AutoCAD-AutoLISP-Reference/files/GUID-7BA45202-D95F-4F2D-8D83-965024826074.htm)
- Status: documented.