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 numbers and strings only (not the any-type domain of eq~/~equal): numbers compare by value across the integer/real tower ((= 1 1.0) returns T), strings by content ((= "abc" "abc") returns T). One-or-more-argument variadic form.
  • (< a b ...) (<= a b ...) (> a b ...) (>= a b ...) — the relational family; same numbers-and-strings domain, with strings ordered lexicographically by character code point. Documented in full alongside this page as Function Entries in chapter 5 ("The Comparison Operators , /, <, <=, >, >=").
  • Domain / error rule for = /= < <= > >=: genuinely incompatible non-nil argument types (a number against a string, e.g. (< 1 "a")) signal a type error; but any argument that is nil makes the result nil without error — bottom (⊥) propagation, consistent with chapter 4 ("Distinguished Object Entry: NIL"): (< 1 nil) = nil, (= nil nil) = nil. This is the sense in which they are more restrictive than eq~/~equal, which accept any type.
  • 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 — a nil argument returns nil, not a type error (⊥ propagation).
  • (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.