Temporarily disable all purity for debug prints

Walter Bright newshound2 at digitalmars.com
Sat Apr 16 12:25:59 PDT 2011


On 4/16/2011 11:52 AM, bearophile wrote:
> Walter:
>
>> Saying it is a safe way to break purity assumes that there was no purpose
>> to the purity. There is no guaranteed safe way to break purity, with or
>> without a compiler switch.
>
> The compiler switch I am talking about doesn't break purity. Its purpose is
> similar to removing the "pure" attributes from the source code. And doing it
> is usually safe, if you do it in the whole program.


No, it is not. You seem to be thinking that purity is just a bug finding or 
optimization feature. That is not so. Purity is a guarantee that can be relied 
upon for a program's behavior. Breaking purity breaks that guarantee.

(Think multithreaded programs, for example.)



> If you take a D2 program, you remove all its pure attributes and you compile
> it again, the result is generally a program just as correct as before.

"generally" is not a verifiable characteristic. When we talk about safety, we're 
talking about a verifiable guarantee.


More information about the Digitalmars-d mailing list