@noreturn?

Steven Schveighoffer schveiguy at yahoo.com
Wed May 16 05:27:34 PDT 2012


On Mon, 14 May 2012 17:59:19 -0400, Timon Gehr <timon.gehr at gmx.ch> wrote:

> On 05/13/2012 06:13 PM, Alex Rønne Petersen wrote:
>> Hi,
>>
>> If memory serves me right, there were some proposals in the past to add
>> a @noreturn attribute to the language. Where did this go?
>>
>> In writing unwinding mechanisms for my VM, I find myself actually
>> needing some sort of @noreturn function attribute that would tell the
>> compiler that the function does not return, rather than having to insert
>> an assert(false); statement.
>>
>
> What about making the compiler detect this pattern instead of adding an  
> attribute? I think it expresses exactly what you want to express, and it  
> does not require additional syntax.
>
> void foo()out{ assert(false); }body{ ... }

Is the out contract required in a method signature?  That is, is it valid  
to omit the out contract in the .di file?

If it's not required, then this doesn't work, since the compiler may not  
have access to that information.

Of course, we could just say "don't make such functions opaque"...

-Steve


More information about the Digitalmars-d mailing list