DIP 1017--Add Bottom Type--Final Review
Johannes Loher
johannesloher at fg4f.de
Thu Jan 17 19:54:10 UTC 2019
Am 17.01.19 um 18:17 schrieb Tim:
> An advantage of the bottom type over an attribute is, that it is part of
> the function type. A library allowing to set a custom error handler
> could specify that the error handler must not return:
> alias ErrorHandler = TBottom function(string msg);
You could also do this with an attribute. Consider the following:
```
void bar() @system
{
}
void main()
{
alias SafeFun = void function() @safe;
SafeFun safeFun = &bar; // Error: cannot implicitly convert
expression & bar of type void function() @system to void function() @safe
}
```
You could do the same thing for an `@noreturn` attribute:
```
alias ErrorHandler = void function(string msg) @noreturn;
```
What I am trying to say: `@noreturn` could also be part of the type of
the function.
More information about the Digitalmars-d
mailing list