On Thu, 29 Sep 2011 13:50:54 -0400, Peter Alexander <peter.alexander...@gmail.com> wrote:

On 29/09/11 12:37 PM, Steven Schveighoffer wrote:
On Wed, 28 Sep 2011 20:11:51 -0400, Peter Alexander
<peter.alexander...@gmail.com> wrote:

On 26/09/11 8:02 PM, Steven Schveighoffer wrote:
I think a better avenue would be to implement some sort of strong-pure
memoization system. Then all you have to do is make an immutable pure
member, and the compiler will take care of the rest for you.

How can the compiler possibly figure out the best way to cache things
for you?

Or have I misunderstood?

It would likely be some sort of tag. Like:

@memoize pure int reallyTimeConsumingMethod() immutable


That's the syntax, but what code would the compiler generate to do the memoization? A hash table of inputs to outputs? That seems really inefficient.

It depends on the situation. The compiler/runtime is free to put it wherever it wants. If it's a class member function, I'd strongly suggest allocating extra space in the instance to store it there.

-Steve

Reply via email to