Special Form Entry: AND

← Prev | ↑ Chapter | Next → | Index | Symbols

Special Form Entry: AND

Name

and

Class

Special Form

Syntax

(and [expr ...])

Arguments and Values

  • zero or more expressions

Description

Computes the logical conjunction of a sequence of expressions.

Evaluation Rules

  • expressions are evaluated left to right
  • evaluation stops as soon as one expression evaluates to nil
  • if no expression evaluates to nil, all expressions are evaluated

Return Values

Returns only T or nil; never the value of any subexpression. and returns T if every expression evaluates to non-nil (and T for the zero-argument form (and)), and nil as soon as one expression evaluates to nil. The value of the last truthy subexpression is not returned.

Side Effects

Side effects are those of the expressions evaluated before short-circuiting stops evaluation, or of all expressions if none evaluates to nil.

Expressions not reached because of short-circuiting are not evaluated and have no side effects.

Exceptional Situations

Malformed syntax is erroneous.

Examples

  • (and T T) => T
  • (and 1 2 3) => T — not 3; the last value does not flow through.
  • (and T nil) => nil
  • (setq r (and 1 2)) stores T in r, not 2.

Compatibility

This differs from Common Lisp and, which returns the value of the last subexpression when every test is true. AutoLISP and returns only T or nil. Confirmed against BricsCAD V26 by direct citation: the BricsCAD V26 and reference page documents the return as "T if all provided arguments evaluate as non-NIL; otherwise NIL". Because the truthy value does not flow through, (and test expr) is not a value-returning when: (setq r (and ok (compute))) stores T, not the computed value. Portable AutoLISP code that needs the computed value must use an explicit conditional, e.g. (if ok (setq r (compute))).

AutoLISP and and or are together the boolean special forms: both return only T or nil and neither returns a subexpression value, so neither can serve as Common Lisp when / or-else / unless. See "Special Form Entry: OR" for the companion rule, and issues/open/autolisp-spec-questions.issue ("AND, OR").

Availability

  • AutoCAD 2026: documented (per Autodesk reference page).
  • BricsCAD V26: documented (BricsCAD V26 dedicated per-symbol page, return: "T if all provided arguments evaluate as non-NIL; otherwise NIL").
  • Status: documented in both vendors. Behaviour confirmed identical (T / nil only) across both vendors; surfaced as a cross-language hazard for code ported from Common Lisp.

See Also

  • "Special Form Entry: OR" — the companion boolean special form; the same T/nil-only return rule applies.

Source Notes