Debug prints in @nogc

Seb via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 30 03:36:06 PDT 2016


On Tuesday, 30 August 2016 at 10:26:28 UTC, Nordlöw wrote:
> I'm struggling with debug printing in my @nogc-containers.
>
> The alternatives:
>
>     assert(false, "Fixed message with no parameters");
>
> is not enough for my needs
>
>     debug writeln("Fixed");
>
> doesn't bypass @nogc checking. Why?
>
> And temporary commenting out @nogc is cumbersome.
>
> I'm aware of C-style printf but that is not as flexible as 
> writeln.
>
> Any advice?

I have experienced the same pain, but afaik there's no good 
solution except commenting or printf and I really wish the debug 
directive would ignore all attribute restrictions and not only 
pure.
To my knowledge the sole good solution is to fix DMD / D.



More information about the Digitalmars-d-learn mailing list