proposed @noreturn attribute

Nick Sabalausky (Abscissa) via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 9 20:25:26 PDT 2017


On 07/09/2017 05:14 PM, H. S. Teoh via Digitalmars-d wrote:
> On Sun, Jul 09, 2017 at 02:01:08PM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
>> On 07/09/2017 12:19 PM, Steven Schveighoffer wrote:
>>> It's no more of a hack than leaving assert(0) in release code.
>>
>> I wouldn't argue that. I do argue it's a hack compared to the
>> principled solution of a bottom type. -- Andrei
> 
> I like out{ assert(0); } for pretty much the same reasons as Steven
> lists. The biggest pro is that **the language already supports it*.
> Contract syntax already is meant to signal intent, and assert(0) signals
> "never gets here". You can't find a better solution than this. All the
> other alternatives require adding even more baggage to an already
> heavy language, or compiler voodoo to recognize a particular pattern of
> defining a type.  I'd say out{assert(0);} is the principled solution --
> expressing something the current language can already express, and it's
> the other alternatives that are "exotic".
> 

Prioritizing "path of least resistense" over "this is cleaner and more 
principled" is the hallmark of C++-style langauge design. Please, 
please, please, let's stay away from that path.


More information about the Digitalmars-d mailing list