patternMinor
Does any language need to have a bottom type?
Viewed 0 times
needanylanguagebottomtypedoeshave
Problem
From wikipedia:
In type theory, a theory within mathematical logic, the bottom type is the type that has no values. It is also called the zero or empty type, and is sometimes denoted with the up tack (⊥) symbol.
The "bottomest" types I can think of in js are
Notice how in TypeScript there is the explicit
The question is/are:
In type theory, a theory within mathematical logic, the bottom type is the type that has no values. It is also called the zero or empty type, and is sometimes denoted with the up tack (⊥) symbol.
The "bottomest" types I can think of in js are
undefined and null, both unity types.Notice how in TypeScript there is the explicit
never bottom type for function that are not supposed to return anything, or to always throw an exception.The question is/are:
- does JavaScript have no bottom type?
- if so, does that mean that languages do not need to have a bottom type?
Solution
Javascript has no bottom type. It does not even really have types in the sense of type theory. Instead, values are tagged with information that is called "dynamic type".
Programming languages typically do not have the bottom type (it is also called the empty type) because they allow defintion by general recursion, which implies that all types are non-empty. For example, to define a value
Programming languages typically do not have the bottom type (it is also called the empty type) because they allow defintion by general recursion, which implies that all types are non-empty. For example, to define a value
v of any type T in Java, we can do this:static T f() { return f(); }
static T v = f();Code Snippets
static T f() { return f(); }
static T v = f();Context
StackExchange Computer Science Q#134225, answer score: 8
Revisions (0)
No revisions yet.