Temporarily disable all purity for debug prints

bearophile bearophileHUGS at lycos.com
Sat Apr 16 06:41:49 PDT 2011


Walter:

> 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).

A compiler switch to disable purity doesn't break purity. It just turns all pure functions inside the program (or inside the compilation unit) into not pure ones. At this point you are allowed to call writeln too, safely. 

A problem: if other already compiled parts of the program use the purity of the functions you have just turn into not pure ones with a compiler switch, your program goes bad. So I presume you have to compile the code that uses the not pure anymore functons.

Bye,
bearophile

Bye,
bearophile


More information about the Digitalmars-d mailing list