Debug prints in @nogc

Johannes Pfau via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 30 10:11:48 PDT 2016


Am Tue, 30 Aug 2016 16:37:53 +0000
schrieb Cauterite <cauterite at gmail.com>:

> On Tuesday, 30 August 2016 at 14:38:47 UTC, Nordlöw wrote:
> > Just being able to print a string is not good enough. I want 
> > the variadic part writeln so I can debug-print values in my 
> > buggy code. Do you have a similar solution?  
> 
> Take a look at the example here:
> http://dlang.org/phobos/std_traits#SetFunctionAttributes
> You could make a `assumeNogc` template similar to the example 
> `assumePure`.
> 
> Oh yeah, here's one I prepared earlier:
> https://dpaste.dzfl.pl/254a5c2697a7

Nice! Here's a slightly modified version:
https://dpaste.dzfl.pl/8c5ec90c5b39

This version does not need an additional delegate. It can be used like
this:

assumeNogc!writefln("foo %s", 42);
assumeNogc!writeln("foo", 42);



More information about the Digitalmars-d-learn mailing list