bottom type as parameter or local variable, does that make sense?
H. S. Teoh
hsteoh at quickfur.ath.cx
Mon Jan 17 18:05:10 UTC 2022
On Mon, Jan 17, 2022 at 05:57:19PM +0000, Paul Backus via Digitalmars-d wrote:
> On Monday, 17 January 2022 at 16:11:03 UTC, Timon Gehr wrote:
> > In D, types that do not have a default constructor cannot be
> > default-constructed. The question is whether `noreturn`, the empty
> > type, should really have a default constructor (that immediately
> > terminates the program). As far as I understand, according to the
> > DIP, `noreturn` has a default constructor, but `noreturn` variables
> > are initialized lazily when they are accessed.
>
> I think the best way to describe the behavior specified by the DIP is
> that the compiler rewrites
>
> noreturn x;
>
> to
>
> noreturn x = void;
>
> So, there is a special case here, but it does not require noreturn to
> have a default constructor.
The question then would be, why such a special case? There's no need to
have a special case here, since aborting/terminating on declaring a
variable of type noreturn is perfectly reasonable semantics for a
bottom type.
T
--
What is Matter, what is Mind? Never Mind, it doesn't Matter.
More information about the Digitalmars-d
mailing list