How do you debug @safe @nogc code? Can't figure out how to print.
Stanislav Blinov
stanislav.blinov at gmail.com
Sat Nov 17 13:43:20 UTC 2018
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);
}
}
> "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.
More information about the Digitalmars-d-learn
mailing list