Bottom type
From Wikipedia, the free encyclopedia
The introduction to this article provides insufficient context for those unfamiliar with the subject. Please help improve the article with a good introductory style. |
The bottom type in type theory is a type that has no values. It is commonly abbreviated as bot, by the up tack symbol (⊥) or by its ASCII approximation _|_. The bottom type is also called the zero or empty type. It contrasts with the top type, which spans all possible values in a system, and a unit type, which has only one value.
The bottom type is frequently used for the following purposes:
- To signal that a function or computation diverges; in other words, does not return a result to the caller. (This does not necessarily mean that the program fails to terminate; a subroutine may terminate without returning to its caller, or exit via some other means such as a continuation.)
- As an indication of error; this usage primarily occurs in theoretical languages where distinguishing between errors is unimportant. Production programming languages typically use exception handling instead.
[edit] In programming languages
In Haskell, the keyword undefined represents a computation for which the result has the bottom type. Attempting to evaluate the computation undefined at runtime aborts the program.
In Common Lisp the symbol NIL, amongst its other uses, is also the name of a type that has no values. It is the complement of T which is the top type. The type named NIL is sometimes confused with the type named NULL, which has one value, namely the symbol NIL itself.
[edit] See also
[edit] External links
- Types and Programming Languages by Benjamin Pierce (MIT Press 2002) [1]