Temporarily disable all purity for debug prints
Nick Sabalausky
a at a.a
Mon Apr 11 19:05:23 PDT 2011
"bearophile" <bearophileHUGS at lycos.com> wrote in message
news:invrod$3182$1 at digitalmars.com...
> 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).
>
That's a very good idea. I'm a huge fan of printf-debugging (comes from
years of developing on platforms that didn't have a good readily-available
debugger), so not being able to do that in pure functions would be a very
critical roadblock for me for using purity. In fact, it's already been a
royal PITA for CTFE.
More information about the Digitalmars-d
mailing list