Normative Rules: Equality Predicates

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

Normative Rules: Equality Predicates

Statement

AutoLISP defines the following equality predicates with the semantics observed in BricsCAD V26 / macOS:

  • (eq a b) — pointer-level identity for cons cells, distinguishes freshly-allocated objects, but returns T for two textually-identical string literals (the host interns string literals), and T for two textually-identical symbol literals (canonical case-folded name).
  • (equal a b) — structural equality over cons cells; numerically compares an integer to a real ((equal 1 1.0) returns T); compares strings by content.
  • (= a b ...) / (/= a b ...) — value equality / inequality over any type, never a type error: numbers compare by value across the integer/real tower ((= 1 1.0) returns T), strings by content ((= "abc" "abc") returns T), anything else by identity like eq ((= 'a 'a) and (= nil nil) return T; (= 1 "1") returns nil). Adjacent pairs, left to right: (/= 1 2 1) returns T.
  • (< a b ...) (<= a b ...) (> a b ...) (>= a b ...) — the relational family over numbers and strings, with strings ordered lexicographically by character code point and nil as the smallest value ((< nil 1) returns T, (< 1 nil) returns nil). Any other pair of non-nil arguments — a number against a string, a symbol, a list — signals a type error. Documented in full alongside this page as Function Entries in chapter 5 ("The Comparison Operators , /, <, <=, >, >=").
  • All six: at least one argument (none is an error, one returns T); adjacent pairs compared left to right, stopping at the first false pair.
  • Truthiness: a value is true iff it is not nil. 0, 0.0, "" are true. nil is the unique false value.

Vendor Evidence

BricsCAD V26 / macOS direct probe section H–J:

  • (equal "abc" "abc") = T ; (eq "abc" "abc") = T — string literals are interned.
  • (equal 1 1.0) = T — cross-type numeric equality.
  • (equal '(1 2) (list 1 2)) = T ; (eq '(1 2) (list 1 2)) = nil — structural vs identity.
  • (= 1 1.0) = T — numeric cross-type equality via =.
  • (= "abc" "abc") = T ; (< "a" "b") = T — = and the relational operators compare strings (verified in BricsCAD V26).
  • (< 1 nil) = nil ; (< "abc" nil) = nil — no type error for a nil argument.

AutoCAD 2022 (French, Windows) and BricsCAD V25 (Windows) / V26 (macOS), comparison-operators probe, 2026-09-25 (240 observations, 237 identical across the vendors):

  • (= 1 "1") = nil ; (= 'a 'a) = T ; (= nil nil) = T ; (= (list 1 2) (list 1 2)) = nil — = never signals; identity for non-numbers/non-strings.
  • (/= 1 2 1) = T — adjacent pairs.
  • (< nil 1) = T ; (<= nil nil) = T ; (> "a" nil) = T — nil is the smallest value.
  • (< 1 "a"), (< 'a 'b) — type error. (<) — error; (< 'a) = T.
  • (>= 'a nil), (> nil 1 "a"), (>= nil 1 "a") — AutoCAD T, nil, nil; BricsCAD type error (AutoCAD adopted).
  • (if 0 'yes 'no) = YES ; (if 0.0 'yes 'no) = YES ; (if "" 'yes 'no) = YES ; (if '() 'yes 'no) = NO.
  • (eq nil '()) = T ; (null nil) = T ; (null '()) = T — nil and the empty list are the same object.

Cross-references

  • "The Comparison Operators , /, <, <=, >, >=" and Function Entries = /= < <= > >= (chapter 5) — the per-operator definitions and the shared argument-type domain.
  • "Distinguished Object Entry: NIL" (chapter 4) — the bottom (⊥) reading that governs the nil-argument exception.
  • Compare CLHS 14.5.1 — CL's eq is finer-grained (does not intern strings).
  • Compare R7RS 6.1 — Scheme distinguishes eqv?, eq?, and equal?.

Source Notes

Phase-6 BricsCAD V26 / macOS semantics probe sections H, I, J.