On 06/20/2017 09:47 AM, jmh530 wrote:
On Tuesday, 20 June 2017 at 15:24:06 UTC, Dukc wrote:


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.

This seems like it only would work if you know that there wouldn't be
any allocations. I don't really know though.

Below is a little more generic:

template gc78f(alias f)
{
    void gc78f(T...)(T what) @nogc
    {
        import std.stdio;
        alias fType = void function(T) @nogc;
        (cast(fType)&f!T)(what);
    }
}

void main() @nogc
{
    import std.stdio;
    string x = "hello world!";
    gc78f!(writeln)(x);
}

And there is also assumeNoGC() which has been discussed before. (The scary thing is, although it happened just five months ago I don't remember taking part in it. :( )

  http://forum.dlang.org/post/oat6lu$n94$1...@digitalmars.com

Ali

Reply via email to