bottom type as parameter or local variable, does that make sense?
maxsamukha at gmail.com
Sun Jan 16 22:56:44 UTC 2022
On Saturday, 15 January 2022 at 18:35:02 UTC, Paul Backus wrote:
> Technically, a variable is a name associated with a block of
> memory, which may or may not contain a value. In the case of
> `noreturn`, the block of memory has size 0, and there are no
> possible values it can contain.
Memory of size 0 contains a single value, which is the value of
the unit type, 0-tuple, or whatever. Zero type is different.
Timon, I am totally confused, could you clarify?
> So, technically, a `noreturn` variable is impossible to
> initialize. But since the compiler knows that the behavior of
> the program can't possibly depend on the variable's value, it
> is free to just skip the initialization altogether and leave
> the variable uninitialized instead.
Sounds like "alias x = noreturn.init;"
> I guess you could make an argument that you should have to
> write `noreturn x = void;` every time you declare a `noreturn`
> variable. But even then, it would not be correct for `noreturn
> x;` to result in an `assert(0)` at runtime--it would have to be
> a *compile-time* error.
I think it depends on the definition of local declaration. For
statics, it is obviously a compile-time error. For locals, my
feeling is it should be a runtime error, but who knows. Timon,
More information about the Digitalmars-d