Bottom type

Bottom type

In type theory, the bottom type is the subtype of all types. It is the return type of a function that does not return normally. As an example, a certain program function may promise to return an integer but in a Turing-complete language the function might get stuck in an infinite loop or encounter an error/exception. In order to theoretically account for the fact that the function might not return an integer in spite of the promise, the bottom type is considered a subtype of integer (and, indeed, all types) even in languages that don't otherwise have subtypes.

Because the bottom type is used to indicate the lack of a normal return, it typically has no values. 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 sometimes confused with the so-called "void type", which is actually a unit type. In the Curry-Howard correspondence, the bottom type is associated with the false formula in logic proofs.

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 other methods, such as option types (including tagged pointers) or exception handling.

Common abbreviations include bot, the "up tack" symbol (⊥) or the ASCII approximation _|_. It is also called the zero or empty type.

In programming languages

Even though the bottom type is an important theoretical aspect to all Turing-complete languages, most commonly used languages don't have a way to explicitly denote it. There are a few notable exceptions.

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.

In Scala, the bottom type is denoted as Nothing. Besides its use for functions that just throw exceptions or otherwise don't return normally, it's also used for covariant parameterized types. For example, Scala's List is a covariant type constructor, so List [Nothing] is a subtype of List [A] for all types A. So Scala's Nil, the object for marking the end of a list of any type, belongs to the type List [Nothing] .

ee also

*NaN

References

*


Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Bottom — can refer to:* Buttocks * Bottom (sex), a term used by gay, BDSM, and some straight couples * Bottom (BDSM) *Nick Bottom, a character from Shakespeare s A Midsummer Night s Dream * Bottom (TV series) , a British sitcom and stage show *The bottom… …   Wikipedia

  • Type 81 assault rifle — Type 81 Type 81 I (top) and Type 81 (bottom). Type Assault rifle Place of origin …   Wikipedia

  • Type vide — Le type vide est en théorie des types un type qui ne comporte pas de valeurs. On l abrège communément par bot (de bottom type), le symbole ( ) ou par l approximation ASCII | . On l appelle aussi parfois type zéro. Il ne faut pas le confondre avec …   Wikipédia en Français

  • Type — Type, n. [F. type; cf. It. tipo, from L. typus a figure, image, a form, type, character, Gr. ? the mark of a blow, impression, form of character, model, from the root of ? to beat, strike; cf. Skr. tup to hurt.] [1913 Webster] 1. The mark or… …   The Collaborative International Dictionary of English

  • Type founder — Type Type, n. [F. type; cf. It. tipo, from L. typus a figure, image, a form, type, character, Gr. ? the mark of a blow, impression, form of character, model, from the root of ? to beat, strike; cf. Skr. tup to hurt.] [1913 Webster] 1. The mark or …   The Collaborative International Dictionary of English

  • Type foundery — Type Type, n. [F. type; cf. It. tipo, from L. typus a figure, image, a form, type, character, Gr. ? the mark of a blow, impression, form of character, model, from the root of ? to beat, strike; cf. Skr. tup to hurt.] [1913 Webster] 1. The mark or …   The Collaborative International Dictionary of English

  • Type foundry — Type Type, n. [F. type; cf. It. tipo, from L. typus a figure, image, a form, type, character, Gr. ? the mark of a blow, impression, form of character, model, from the root of ? to beat, strike; cf. Skr. tup to hurt.] [1913 Webster] 1. The mark or …   The Collaborative International Dictionary of English

  • Type metal — Type Type, n. [F. type; cf. It. tipo, from L. typus a figure, image, a form, type, character, Gr. ? the mark of a blow, impression, form of character, model, from the root of ? to beat, strike; cf. Skr. tup to hurt.] [1913 Webster] 1. The mark or …   The Collaborative International Dictionary of English

  • Type wheel — Type Type, n. [F. type; cf. It. tipo, from L. typus a figure, image, a form, type, character, Gr. ? the mark of a blow, impression, form of character, model, from the root of ? to beat, strike; cf. Skr. tup to hurt.] [1913 Webster] 1. The mark or …   The Collaborative International Dictionary of English

  • Bottom-up parsing — (also known as shift reduce parsing) is a strategy for analyzing unknown data relationships that attempts to identify the most fundamental units first, and then to infer higher order structures from them. It attempts to build trees upward toward… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”