Jason House wrote:
Andrei Alexandrescu wrote:

That's way beyond the ability of a compiler to do automatically. The compiler would have to understand that the pure function produces continuous results.
You're replying to the wrong guy. I'm saying: the compiler shouldn't have to do so, but it should allow functions to do it.

So effectiely, the compiler could just trust pure functions to be actually pure, with UB for any that isn't?

Here's the simplest memoization example I could come up with.

You mean the simplest example beyond just remembering a single property value?

Maybe we should try to figure out how to get this to work and then
expand to other cases?
<snip>
Note the thread-local static variable.  That's guaranteed to be
thread safe and is easy to prove that it has no side effects outside
of the fibonocci function.

Inevitably, I've embarrassed myself by not actually passing what I
thought was simple code through a compiler...
<snip>

Indeed.

Stewart.

Reply via email to