Skip to main content

t

t Constant Variable

Constant Value:

t.

Description:

The boolean representing true, and the canonical generalized boolean representing true. Although any object other than nil is considered true, t is generally used when there is no special reason to prefer one such object over another.

Data and Control

The symbol t is also sometimes used for other purposes as well. For example, as the name of a class, as a designator (e.g., a stream designator ) or as a special symbol for some syntactic reason (e.g., in case and typecase to label the otherwise-clause).

Examples:

t → T 
(eq t ’t) → true
(find-class ’t) → #<CLASS T 610703333>
(case ’a (a 1) (t 2))1
(case ’b (a 1) (t 2))2
(prin1 ’hello t)
▷ HELLO
→ HELLO

See Also:

nil

Expanded Reference: t

t as Boolean True

t is the canonical true value in Common Lisp. Predicates conventionally return t for true, though any non-nil value counts as true.

(if t "true" "false")
=> "true"

;; Predicate results
(numberp 42)
=> T
(stringp "hello")
=> T
(eq t t)
=> T

;; Not and boolean operations
(not t)
=> NIL
(and t t t)
=> T
(or nil t)
=> T

t as a Type Specifier

As a type specifier, t denotes the supertype of all types -- every object is of type t.

(typep 42 t)
=> T
(typep "hello" t)
=> T
(typep nil t)
=> T
(typep #'car t)
=> T

;; t is the supertype of everything
(subtypep 'integer t)
=> T
=> T
(subtypep 'string t)
=> T
=> T
(subtypep 'null t)
=> T
=> T

t in CLOS as the Superclass

In the object system, the class t is the superclass of all classes.

;; Every class inherits from t
(find-class t)
==> #<BUILT-IN-CLASS COMMON-LISP:T>

;; Checking class precedence
(not (null (member (find-class t)
(sb-mop:class-precedence-list (find-class 'integer)))))
=> T

t Cannot Be Rebound

Like nil, t is a constant variable and cannot be used as a variable name.

;; t is a symbol that evaluates to itself
(symbolp t)
=> T
(symbol-name t)
=> "T"
(eq t 't)
=> T

;; These would signal errors:
;; (setq t 5) → error
;; (let ((t 5)) t) → error