The "no gc" crowd

Walter Bright newshound2 at digitalmars.com
Tue Oct 8 15:53:35 PDT 2013


On 10/8/2013 3:45 PM, Adam D. Ruppe wrote:
> On Tuesday, 8 October 2013 at 22:37:28 UTC, Walter Bright wrote:
>> Every function an @nogc function calls will also have to be @nogc.
>
> Eh, not necessarily. If it expands to static
> assert(!__traits(hasAnnotationRecursive, uses_gc));, then the only ones that
> *need* to be marked are the lowest level ones. Then it figures out the rest only
> on demand.
>
> Then, on the function you care about as a user, you say nogc and it tells you if
> you called anything and the static assert stacktrace tells you where it happened.
>
> Of course, to be convenient to use, phobos would need to offer non-allocating
> functions, which is indeed a fair amount of work, but they wouldn't
> *necessarily* have to have the specific attribute.

What you're suggesting is called "interprocedural analysis" and doesn't work in 
a system with separate compilation (meaning that function bodies are hidden from 
the compiler).


More information about the Digitalmars-d mailing list