DIP 1034--Add a Bottom Type (reboot)--Formal Assessment Begins

Imperatorn johan_forsberg_86 at hotmail.com
Wed Feb 3 22:41:08 UTC 2021


On Wednesday, 3 February 2021 at 19:00:20 UTC, Dennis wrote:
> On Wednesday, 3 February 2021 at 18:24:06 UTC, Imperatorn wrote:
>> Is there a short explanation of why this was done and what it 
>> enables?
>
> It is done to give better semantics to certain things that 
> currently have special cases in the compiler. E.g. the compiler 
> has an internal list of functions that don't return, and 
> `typeof(null)` is a bit of a special case.
>
> This enables:
>
> - Writing your own 'panic' function that the compiler knows 
> terminates control flow (similar to assert(0)) so you don't 
> have to write an unreachable `return` or `break`.
> - Throwing exceptions in lambda's: `() => throw new 
> Exception("")`
> - Accepting `null` in a template taking a generic pointer `T*`
> - Recognizing the empty list `[]` in template functions 
> (currently it is a `void[]`)

Thanks for the clarification(s)! 🍀


More information about the Digitalmars-d-announce mailing list