<br><font size=2 face="sans-serif">Yeah, memorization is a good way to
put it. The closest thing I've seen to this was from a friend of
mine who was using aspects to implement method level caching in java. This
of course is not supported by the language itself.</font>
<br><font size=2 face="sans-serif">____________________________________________<br>
Dennis Byrne<br>
ThoughtWorks - Chicago<br>
312-505-7965<br>
<br>
</font>
<br>
<br><tt><font size=2>"Brandon Black" <blblack@gmail.com>
wrote on 11/04/2007 07:52:02 AM:<br>
<br>
> <br>
</font></tt>
<br><tt><font size=2>> On 11/4/07, Dennis Byrne <dbyrne@thoughtworks.com>
wrote:</font></tt>
<br><tt><font size=2>> <br>
> Hello Ulf, <br>
> <br>
> If you have a function that is 100% predictable, couldn't there be
<br>
> some serious performance gains given that the function is frequently
<br>
> passed the same message? In other words, why put a core to work
<br>
> calculating the result you gave last time someone sent you a given
<br>
> message? It would be better to use this function to spawn a
process <br>
> that could use the process dictionary as a cache (one that would neverexpire).
</font></tt>
<br><tt><font size=2>> <br>
> <br>
> What you're basically asking for there is memoization. It would
be <br>
> interesting to have memoization supported at the language level. The
<br>
> compiler/interpreter isn't smart enough to know when memoization makes<br>
> the most sense (depends on freq/range of inputs, computational <br>
> complexity of function), but the programmer probably knows. You
would<br>
> need a syntax for specifying function "attributes" to the
<br>
> compiler/interpreter. Borrowing the ":attrib" syntax
from Perl, it <br>
> would look like: <br>
> <br>
> somecomplexfunc(X) :memoize -> ... complex body ...<br>
> <br>
> I'm guessing that analysis tools could easily throw an error at you
if<br>
> you've put :memoize on a function which (directly or indirectly by
<br>
> calling other funcs) makes use of mutable state. </font></tt>
<br><tt><font size=2>> <br>
> -- Brandon</font></tt>