Bottom type DIP 1017 and final rejection reasons?

Johannes Loher johannes.loher at fg4f.de
Mon Mar 30 20:12:36 UTC 2020


Am 30.03.20 um 21:33 schrieb aliak:
> Why does typeof(null) become noreturn*>
> And is the only use case for noreturn[] being able to map on a "void"
> array? Or are there other use cases?
> 
> What's the use-case for being able to declare a variable of type noreturn?
> 

noreturn is the type that has no values. Hence a value of type noreturn*
is a pointer that never points to a value. null is the only value a
pointer can have for this to be true, i.e. the only value that noreturn*
could have is null. On the other hand, all pointer types in D can hold
null and it would be weird and arbitrary to change this for noreturn*.
So noreturn* is the type that holds exactly one value, null. But this is
also the definition of the type typeof(null).

Basically, what I wrote boils down to it just being the most consistent
choice.

The same argument shows that making typeof([]) become noreturn[] is also
the best choice.

One major benefit you get from all of this is that you do not have to
consider noreturn as a special case in generic code. It behaves just
like any other type (well except for void, which unfortunately still
needs to be special cased :().


More information about the Digitalmars-d mailing list