Purity with references and pointers
Kagamin
spam at here.lot
Mon Sep 20 04:20:57 PDT 2010
Jonathan M Davis Wrote:
> If a pure function takes a reference/pointer, does that state that the result of
> the function will be the same on two calls to it if the reference/pointer points
> 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 could
> have and should have been different for each call because the object pointed to
> 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.
More information about the Digitalmars-d-learn
mailing list