Life in the Fast Lane (@nogc blog post)

Dukc via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Jun 20 08:24:06 PDT 2017


On Tuesday, 20 June 2017 at 09:56:03 UTC, Bastiaan Veelo wrote:

> Transferring this to GC, you could have @gc (the default), 
> @nogc (the @safe equivalent) and the @trusted equivalent: 
> @gc_code_that_is_acceptable_to_be_called_in_nogc_code_as_an_exception_to_the_rule. I'll abbreviate this as @gc78 until there is a better name.

It can already be done:

void gc78writeln(string what) @nogc
{   import std.stdio;
     alias WritelnType = void function(string) @nogc;
     (cast(WritelnType)&writeln!string)(what);
}

void main() @nogc
{   import std.stdio;
     gc78writeln("hello world!");
}

I wasn't skilled enough to make a generic version of this trough. 
And I do not know what happens if @nogc function ends up calling 
gc.


More information about the Digitalmars-d-announce mailing list