DIP 1017--Add Bottom Type--Final Review
Johannes Loher
johannes.loher at fg4f.de
Wed Jan 16 08:47:48 UTC 2019
On Tuesday, 15 January 2019 at 18:51:13 UTC, Johannes Loher wrote:
> [...]
18.
> A point was raised that Tbottom* == typeof(null) and Tbottom[]
> == typeof([]) would be preferable to both cases equating to
> Tbottom.
I totally agree with this criticism. What does `Tbottom*` mean
conceptually? It is a type which can hold either an address where
a `Tbottom` is located, or `null`. However, there cannot be any
address where a `Tbottom` is located, because `Tbottom` does not
have any values. This means that `Tbottom*` is a type which can
hold exactly one value: `null`.
By the way, Kotlin does basically the same thing. Kotlin does not
have pointers, but it has optional types and the type `Nothing?`
is a type which can hold exactly one value: `null`. This also
means that it is basically a unit type. While it is not actually
Kotlin's `Unit` type, it could have been. Similarly, should we
decide to go down that road and add proper top, bottom and unit
types, we could define
```
alias Tbottom = typeof(assert(0));
alias void = Tbottom*;
```
More information about the Digitalmars-d
mailing list