Bottom Type--Type Theory

Johannes Loher johannesloher at fg4f.de
Thu Jan 17 21:56:00 UTC 2019


Am 17.01.19 um 22:29 schrieb Neia Neutuladh:
> On Thu, 17 Jan 2019 21:48:52 +0100, Johannes Loher wrote:
>> I don't actually think declaring a variable of the Bottom type is
>> required to be illegal. It just needs to be impossible for it to ever be
>> initialized.
> 
> Which runs into default-initialization, so that's not awesome. But the 
> same is true of structs with `@disable this();`
> 
> If we treated them the same, you'd still be able to write:
> 
>     TBottom var = void;
>     doStuff(var);
> 
> That's...not awesome.
> 
By the way, I think it is debatable whether variables of type Tbottom
should be declarable or not. The inconsistencies (in particular no void
initialization which every other type has) are indeed a reason to not
allow this. But then again, this is also an inconsistency: All other
types are declarable, except for void (which should also be fixed in my
opinion).

There are quite a few languages which allow declaration of variables of
their bottom type in the manner I described. These include:
- Rust
- Kotlin
- Flow
- Haskell
- Swift

On the other hand, I don't know of any language which prevents this. Do
you know any?



More information about the Digitalmars-d mailing list