Can you suggest any example Common Lisp programs that print the _types_ NULL or NIL or T? Or show off the benefits of this spindle arrangement? I can intuitively see the benefits of this approach, but an example makes things much more memorable.
The nice thing about T is that it's the first letter of True and of Type. E.g.
;; catch-all method for any type
(defmethod foo ((arg t)) ...)
;;
(defmethod foo (arg ...) ...) ;; alternative spelling: omit class
NIL is the empty list and that is mnemonic for "empty type". For instance, the intersection of two mutually exclusive types is the empty type. Nothing can be both a cons and an atom, so the type denoted by the type expression (and cons atom) is empty; and that is nil. The set manipulation which underlies types needs an empty set, and nil fill the need for that empty set (pun intended).
NULL is useful in writing methods that capture NIL (the only instance of NULL). That may be recognized as the "null object pattern":
(defmethod foo ((arg null))
;; (foo nil) called
)
(defmethod foo ((arg number))
;; (foo <number>) called
)
(defmethod foo ((arg t))
;; (foo <anything else>) called
)
Can you suggest any example Common Lisp programs that print the _types_ NULL or NIL or T? Or show off the benefits of this spindle arrangement? I can intuitively see the benefits of this approach, but an example makes things much more memorable.