Special Form Entry: IF
← Prev | ↑ Chapter | Next → | Index | Symbols
Special Form Entry: IF
Name
if
Class
Special Form
Syntax
(if testexpr thenexpr [elseexpr])
Arguments and Values
testexpr: an expressionthenexpr: an expressionelseexpr: an expression; optional
Description
Conditionally evaluates one of two branches.
Evaluation Rules
- evaluate
testexpr - if result is non-nil, evaluate
thenexpr - otherwise evaluate
elseexprif supplied
Return Values
- returns the selected branch value
- if
elseexpris absent and the test is false, returns nil
Side Effects
Side effects are those of:
- the evaluation of
testexpr, which always occurs, - the evaluation of
thenexprwhentestexpris non-nil, - the evaluation of
elseexprwhentestexpris nil andelseexpris present.
The non-selected branch is not evaluated and has no side effects.
Exceptional Situations
Malformed syntax is erroneous.
Examples
(if T 1 2) => 1(if nil 1 2) => 2
Compatibility
Stable across vendors.
Notes
Conditional truth is based on nil versus non-nil.
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
- [if (AutoLISP)](https://help.autodesk.com/cloudhelp/2024/PLK/AutoCAD-LT-AutoLISP-Reference/files/GUID-916F1A5C-FD70-4D66-897E-6DCD666DCB39.htm)
- Status: documented.