On Thu, 16 Jun 2011 06:52:45 -0400, Michel Fortin wrote: > On 2011-06-15 23:29:46 -0400, Charles McAnany <[email protected]> > 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.
If you want a strongly pure function, the parameters need to be immutable or implicitly convertible to immutable. const references may be mutated elsewhere. -Lars
