On Mon, 20 Sep 2010 16:26:44 -0400, Don <nos...@nospam.com> wrote:
Steven Schveighoffer wrote:
I think it's ok for a function to be pure if all the arguments are
unshared, regardless of immutability. However, in order to cache the
return value, the reference itself must not be used as the key, but the
entire data of the reference. Even if it's immutable, wouldn't you not
want to cache the return values between two identical immutable objects?
Possibly, but my guess is that it would take too long to check.
This is why I hate the idea of automatic caching -- how does the compiler
know that it would be too long? What if the operation takes 15 seconds,
and to do the memcmp takes 15 milliseconds?
-Steve