DIP60: @nogc attribute

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 15 12:18:53 PDT 2014


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.


More information about the Digitalmars-d mailing list