Temporarily disable all purity for debug prints

Walter Bright newshound2 at digitalmars.com
Fri Apr 15 19:25:42 PDT 2011


On 4/15/2011 7:06 PM, bearophile wrote:
> There is something I don't understand. If your last change allows code like
> this, isn't it breaking the safety of pure functions in debug mode? Do you
> think this loss of safety is not important?

Yes, it allows one to break the purity of the function. The alternative is to 
use casts (which also breaks the purity) or another compiler switch (which also 
breaks the purity).

Any escape from the language rules requires the programmer to know what they're 
doing, as the compiler can't check it for them.

D is a systems programming language, and so it does allow escapes from the 
rules. It's very useful to allow an I-know-what-I'm-doing escape from the purity 
rules.



More information about the Digitalmars-d mailing list