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)! 🍀

Reply via email to