On Saturday, 17 November 2018 at 13:43:20 UTC, Stanislav Blinov wrote:
On Saturday, 17 November 2018 at 13:13:36 UTC, aliak wrote:

Sawweet! Thanks, that made the printing possible!

You're welcome ;) Still, try a more recent compiler. This works fine:

void foo() @nogc {
    debug {
        import std.stdio;
        writefln("%d", 42);
    }
}

Yeah that does, but not the code I posted -> https://run.dlang.io/is/vH3cFa

You can use "debug blah" to hide inside functions that are attributed, but when you have an attributed function that calls a template, attribtues of which are supposed to be inferred, it seems to fail.

Maybe a bug if it's supposed to work?


"scope" is const from what I understand right? It works without scope as well. So just "return T".

No, "scope" means "does not escape scope", i.e. you can't assign that argument to some global. The only exception is through a return, in which case "return" also needed. Whether or not just "return" is sufficient, is a bit out there still (AFAIK), between DIP25, DIP1000 and current state of the language. "scope" was implemented for delegates for ages now, exactly to allow passing lambdas around without allocating their context on the GC heap.

Aha, cool. Thanks!

Reply via email to