proposed @noreturn attribute

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 8 11:42:09 PDT 2017


On 7/8/17 1:30 PM, Stefan Koch wrote:
> On Saturday, 8 July 2017 at 17:14:32 UTC, Andrei Alexandrescu wrote:
>>
>> What is the signature of a function that logs something to a file and 
>> ends in assert(0)?
>>
> 
> I do get your point.
> However I still doubt that this is worth a the additional language 
> complexity.

Yah, there's marginal utility only - improves code generation and makes 
a few awkward workarounds unnecessary. Yet many other languages and 
implementations have it, so apparently the utility is justifiable.

> Usually the clue would be in the name.
> sth. like
> void logAndDie(string lastWords) { ... }

Problem here being this code is opaque to compile-time analysis and to 
introspection. Unless, that is, the compiler understands the name 
(smell) or the introspection does heuristics on name - e.g. everything 
that ends in "andDie" does not return (smell). -- Andrei


More information about the Digitalmars-d mailing list