DIP60: @nogc attribute

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 25 06:20:08 PDT 2014


On Friday, 25 April 2014 at 12:59:55 UTC, Steven Schveighoffer 
wrote:
> On Fri, 25 Apr 2014 08:21:38 -0400, David Nadlinger 
> <code at klickverbot.at> wrote:
>
>> On Friday, 25 April 2014 at 12:07:00 UTC, Steven Schveighoffer 
>> wrote:
>>> One interesting thing about this is that the compiler 
>>> implementation may make some @nogc code valid on some 
>>> compilers, and invalid on others, even though the resulting 
>>> execution is the same.
>>
>> I don't think this is a desirable behavior. @nogc should be 
>> decided in the frontend, before closure allocation 
>> optimizations take place.
>
> I don't know that it's desirable to have @nogc reject code even 
> though an allocation does not occur. I agree the situation is 
> not ideal, but @nogc is a practical optimization.
>
> I can think of other cases where the GC may be optimized out. 
> To reject such code in @nogc would make it much less attractive.
>
> -Steve

It is unacceptable to have code that fails with one compiler and 
works with the other despite the shared frontend version. Such 
"enhanced" @nogc attributes must be placed into compiler-specific 
attribute space and not as a core language feature.


More information about the Digitalmars-d mailing list