proposed @noreturn attribute

Nicholas Wilson via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 18 19:14:33 PDT 2017


On Wednesday, 19 July 2017 at 01:52:30 UTC, Walter Bright wrote:
> I know how noreturn attributes work - I implemented them 
> decades ago in DMC and DMC++. They are supported by the DMD 
> optimizer and back end.
>
> But they are a hack to the type system, and I suggest an 
> unnecessary one.

It describe the behaviour of the function: I think it is neither 
necessary nor a good idea to express it as a type. assert(0) is 
already accepted as a valid return statement of any type.

> The backends for DMD, LDC and GDC would not be affected at all 
> by the addition of a bottom type to the front end, and it would 
> be trivial for the glue code to add the noreturn attribute for 
> functions that return the bottom type.

Said glue would be unnecessary with an attribute *that already 
exists*.


More information about the Digitalmars-d mailing list