www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Re: Purity with references and pointers

Jonathan M Davis Wrote:

 If a pure function takes a reference/pointer, does that state that the result
 the function will be the same on two calls to it if the reference/pointer
 to the same data in both cases or if the data itself is unchanged?
 If it's a matter of pointing to the same data, then that could be horribly 
 broken. That would mean that as long as I pased in the same reference, the 
 compiler could cache the result but that the actual result of the function
 have and should have been different for each call because the object pointed
 was altered.

You can search for bug report about purity of stdc string functions. Don proposed two flavors of purity. When you pass const data to pure function, the call effectively becomes impure.
Sep 20 2010