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 expression
  • thenexpr: an expression
  • elseexpr: an expression; optional

Description

Conditionally evaluates one of two branches.

Evaluation Rules

  • evaluate testexpr
  • if result is non-nil, evaluate thenexpr
  • otherwise evaluate elseexpr if supplied

Return Values

  • returns the selected branch value
  • if elseexpr is 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 thenexpr when testexpr is non-nil,
  • the evaluation of elseexpr when testexpr is nil and elseexpr is 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.