Pure not acting pure.

Michel Fortin michel.fortin at michelf.com
Thu Jun 16 03:52:45 PDT 2011


On 2011-06-15 23:29:46 -0400, Charles McAnany <mcanance at rose-hulman.edu> said:

> Ah, so does the compiler figure out which ones are strongly and weakly 
> pure and then optimize as
> appropriate? Is there a way to indicate that a function is strongly 
> pure? Because it would seem odd
> to call a function you thought was pure and wind up with a mutated argument.

Just make sure all the parameters are either const or immutable or 
passed by copy and do not contain any pointer or reference. That'll 
make the function strongly pure, and the compiler will be able optimize.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d-learn mailing list