DIP60: @nogc attribute
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Tue Apr 15 23:27:31 PDT 2014
On 4/15/14, 12:18 PM, Dicebot wrote:
> On Tuesday, 15 April 2014 at 19:12:30 UTC, Steven Schveighoffer wrote:
>> int isthisok(int x, int y) @nogc
>> {
>> // need scratch space
>> int[] buf = new int[x * y];
>> scope(exit) GC.free(buf.ptr);
>> // perform some algorithm using buf
>> ...
>> //
>> return buf[$-1];
>> }
>>
>> Valid?
>
> No way. This can trigger GC collection. @nogc is not about observable
> pre- and post- state but about prohibiting specific operation completely.
Very nice. This is a preemptive close of an entire class of arguments.
-- Andrei
More information about the Digitalmars-d
mailing list