Temporarily disable all purity for debug prints

bearophile bearophileHUGS at lycos.com
Mon Apr 11 14:27:41 PDT 2011


>From what I am seeing, in a D2 program if I have many (tens or more) pure functions that call to each other, and I want to add (or activate) a printf/writeln inside one (or few) of those functions to debug it, I may need to temporarily comment out the "pure" attribute of many functions (because printing can't be allowed in pure functions).

As more and more D2 functions become pure in my code and in Phobos, something like a -disablepure compiler switch (and printf/writeln inside debug{}) may allow more handy debugging with prints (if the purity is well managed by the compiler then I think disabling the pure attributes doesn't change the program output).

Bye,
bearophile


More information about the Digitalmars-d mailing list