Temporarily disable all purity for debug prints

dennis luehring dl.soluz at gmx.net
Sun Apr 17 13:30:28 PDT 2011


On 11.04.2011 23:27, bearophile wrote:
>  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

sounds a little bit like the need to see an private/protected part of an 
interface in unittest scenarios - just to be able to test it in a 
whitebox-testing without changing the attributes of the productive-code

we need a solution for both


More information about the Digitalmars-d mailing list