The Comparison Operators , /, <, <=, >, >=
← Prev | ↑ Chapter | Next → | Index | Symbols
The Comparison Operators , /, <, <=, >, >=
The six comparison operators =, /=, <, <=, >, and >= are documented here, next to eq and equal, because they are general comparison predicates: they compare numbers and strings, not numbers only. (Chapter 8, "Numbers", carries a forward-reference to this location.) They differ from eq and equal, which accept arguments of any type: the comparison operators carry a more restrictive argument-type domain — numbers and strings — with a type error on genuinely incompatible non-nil argument types.
Accepted argument-type domain (shared rule)
- Numbers compare by value across the integer/real tower — e.g.
(= 1 1.0) => T— under the coercion rules of "Normative Rules: Number Tower and Division" (chapter 3 / chapter 8). - Strings compare by content, and the ordering operators (
<<=>>=) order them lexicographically by character code point, left to right. String comparison was verified in BricsCAD V26. - Mixed, genuinely incompatible non-nil types — a number against a string, e.g.
(< 1 "a")or(= 1 "1")— signal a type error. The nil / bottom (⊥) exception: when any argument is
nil, the operator does not signal; it returnsnil(⊥ in, ⊥ out). This is the same bottom-propagation rule tracked for thenildistinguished object in chapter 4 (see "Distinguished Object Entry: NIL"). Thus:(< 1 nil) => nil ; no error (< "abc" nil) => nil ; no error (= 1 nil) => nil ; no error (>= nil 1) => nil ; no error (= nil nil) => nil ; ⊥ in, ⊥ out (consistent with chapter 4) (< 1 "a") -> TYPE ERROR ; two incompatible non-nil types
The type-error check therefore fires only when all offending arguments are non-nil-but-incompatible; a nil anywhere short-circuits the chain to nil.
- Variadic chaining holds for strings exactly as for numbers:
(< "a" "b" "c")tests each argument against the one to its right, left to right.
See also "Normative Rules: Equality Predicates" (chapter 3), which states these operators alongside eq~/~equal.