Question about @nogc

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 20 06:57:01 PDT 2014


On Tuesday, 20 May 2014 at 12:25:11 UTC, Dominikus Dittes Scherkl 
wrote:
> Did I understand correct that a function can only be @nogc if 
> also all functions that it calls are @nogc too (and of course 
> it doesn't use the GC itself)?
>
> If so, should this be possible:
>
> string foo()
> {
>    // use GC to allocate some string
> }
>
> bar @nogc
> {
>    mixin(foo());
> }
>
> Because, bar() didn't really call foo() but instead foo() is 
> evaluated during compile time and it's result is now part of 
> the code, right?

Right.

It's the same mechanics you'd get from pure/nothrow and 
@safe+ at trusted


More information about the Digitalmars-d-learn mailing list