Temporarily disable all purity for debug prints

David Gileadi gileadis at NSPMgmail.com
Tue Apr 12 08:17:53 PDT 2011


On 4/12/11 1:12 AM, spir wrote:
> On 04/12/2011 04:05 AM, Nick Sabalausky wrote:
>>> 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.
>
> Same for me. I'm a fan of printf debugging not because of lack of
> debuggers, rather because of their "heaviness" & lack of flexibility.
> Debug output is by me far more direct, quicker & lighter; and agile.
>
> Denis

I'm not a day-to-day D programmer but it's seemed to me for a while that 
having a print/log function that would work in normal code, in pure code 
and in CTFE would be extremely useful.


More information about the Digitalmars-d mailing list