proposed @noreturn attribute

Random D user via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 11 12:53:37 PDT 2017


On Saturday, 8 July 2017 at 12:18:38 UTC, Andrei Alexandrescu 
wrote:
> On 7/8/17 7:07 AM, bachmeier wrote:
>> On Saturday, 8 July 2017 at 10:15:39 UTC, Walter Bright wrote:
>> 
>>> Having an @noreturn attribute will take care of that:
>>>
>>>    @noreturn void ThisFunctionExits();
>> 
>> Why should this be an attribute rather than a pragma?
>
> So it's part of the summary of the function. -- Andrei

If it feels like a pragma, should be part of the function and 
reflectable, then how about:

void assertFalse(bool cond) @pragma(noreturn)

or

void assertFalse(bool cond) @pragma("noreturn")

The compiler could probably give an error if the "" (inside 
@pragma) wasn't a known string.
Also @pragma would be useful as standard way of saying "special 
compiler attribute". No need to consume global attribute 
namespace.

I'm expecting to see @myproject_safe and @myproject_noreturn type 
of attributes someday in some project :|


More information about the Digitalmars-d mailing list