@gc attribute for bypassign @nogc

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 28 13:32:18 PDT 2016


On Thursday, 28 July 2016 at 18:53:35 UTC, Meta wrote:
> On Thursday, 28 July 2016 at 00:23:57 UTC, bitwise wrote:
>> While working on a past project(C++), I found this little gem:
>>
>> void draw() {
>>     Font* f = new Font("arial.ttf", 16);
>>     drawText(f, "hello world");
>> }
>
> It sounds like -vgc and --profile=gc are exactly what you want. 
> @nogc is meant to *guarantee* that the GC will not be called 
> within a function or any other functions called by that 
> function. Taking that guarantee away makes it effectively 
> useless.

I understand that @assumenogc may not be exactly the right 
approach, but the underlying idea is sound, which is to have the 
compiler to disallow all GC allocations in some annotated scope, 
just like @nogc, but to allow the programmer to override the 
@nogc restriction in certain cases.

There may be alternative approaches, and the @warngc idea was 
just one random suggestion.

The point is, a mixture of @nogc and @assumenogc would achieve 
exactly what I'm looking for. The only problem is that it may 
cause issues for people that are using @nogc under a different 
set of assumptions.

     Bit



More information about the Digitalmars-d mailing list