Relation with the empty type
When the bottom type is uninhabited, a function whose return type is bottom cannot return any value, not even the lone value of aComputer science applications
In subtyping systems, the bottom type is a subtype of all types. It is dual to thenull
is the only value of the null type; and it can be cast to any reference type. However, the null type is not a bottom type as described above, it is not a subtype of int
and other primitive types.
# A type system including both Top and Bot seems to be a natural target for In programming languages
Most commonly used languages don't have a way to denote the bottom type. There are a few notable exceptions. InVoid
.
In NIL
, contains no values and is a subtype of every 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 othing/code> is a subtype of List /code> 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 othing/code>.
In Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH) ...
, the bottom type is called the never type and is denoted by !
. It is present in the type signature of functions guaranteed to never return, for example by calling panic!()
or looping forever. It is also the type of certain control-flow keywords, such as break
and return
, which do not produce a value but are nonetheless usable as expressions.
In Ceylon
Sri Lanka, officially the Democratic Socialist Republic of Sri Lanka, also known historically as Ceylon, is an island country in South Asia. It lies in the Indian Ocean, southwest of the Bay of Bengal, separated from the Indian subcontinent, ...
, the bottom type is Nothing
. It is comparable to Nothing
in Scala and represents the intersection of all other types as well as an empty set.
In Julia, the bottom type is Union
.
In TypeScript
TypeScript (abbreviated as TS) is a high-level programming language that adds static typing with optional type annotations to JavaScript. It is designed for developing large applications and transpiles to JavaScript. It is developed by Micr ...
, the bottom type is never
.
In JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
with Closure Compiler annotations, the bottom type is !Null
(literally, a non-null member of the Null
unit type
In the area of mathematical logic and computer science known as type theory, a unit type is a type that allows only one value (and thus can hold no information). The carrier (underlying set) associated with a unit type can be any singleton set. ...
).
In PHP, the bottom type is never
.
In Python's optional static type annotations, the general bottom type is typing.Never
(introduced in version 3.11), while typing.NoReturn
(introduced in version 3.5) can be used as the return type of non-returning functions specifically (and doubled as the general bottom type prior to the introduction of Never
).
In Kotlin, the bottom type is Nothing
.
In D, the bottom type is noreturn
.
In Dart, since version 2.12 with th
sound null safety update
the Never
type was introduced as the bottom type. Before that, the bottom type used to be Null
.
See also
*Contradiction
In traditional logic, a contradiction involves a proposition conflicting either with itself or established fact. It is often used as a tool to detect disingenuous beliefs and bias. Illustrating a general tendency in applied logic, Aristotle's ...
* Fail-stop
* NaN
*Top type
In mathematical logic and computer science, some type theories and type systems include a top type that is commonly denoted with top or the symbol ⊤. The top type is sometimes called also ''universal type'', or ''universal supertype'' as all oth ...
*Unit type
In the area of mathematical logic and computer science known as type theory, a unit type is a type that allows only one value (and thus can hold no information). The carrier (underlying set) associated with a unit type can be any singleton set. ...
References
Further reading
*
{{DEFAULTSORT:Bottom Type
Data types
Type theory