dsimcha wrote:
You misunderstood the question. I mean, at the implementation level, even though it wouldn't be visible to the programmer, the AA that did the memoization would have to be mutable so it could be modified when a new value was to be memoized. This is where the threading issues would come in. What I was saying is that synchronizing on this would be bad for obvious reasons, and TLS would still not be great because you wouldn't be able to share memoized values across threads.
You're right, I hadn't thought of that. But you could do a per-thread memoization using thread local storage. No sync problems.