proposed @noreturn attribute
John Colvin via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 8 11:26:33 PDT 2017
On Saturday, 8 July 2017 at 12:17:57 UTC, Andrei Alexandrescu
wrote:
> On 7/8/17 6:15 AM, Walter Bright wrote:
>> Has anyone a better idea? Does anyone want to write a DIP for
>> this?
>
> An attribute is fine. A more PL-minded possibility is to return
> a specific type:
>
> struct None
> {
> @disable this();
> @disable this(this);
> @disable @property None init();
> }
>
> None ThisFunctionExits();
>
> The compiler detects (without having anything hardwired about
> the particular type "None") that the type None is impossible to
> create and copy/move from a function, and therefore decrees the
> function will never return.
>
>
> Andrei
I wonder if some lessons from Haskell's "bottom" type would be
relevant here.
More information about the Digitalmars-d
mailing list