On Jun 27, 2007, at 5:12 PM, Chuck Esterbrook wrote:

The functional programming term for this is memoization, and not only
does it do this automatically, but it provides the added benefit of
being able to prove when a cached value can be safely reused (the
logic you describe works great with functional programming, but
because of the wonders of state and side effects, it is much more
difficult to prove in a non-functional context).
Anyway, I just read this statement: "However, memo-functions are not
supported in Haskell, so we will need to do some extra work to
construct and use an explicit cache." Chris, does this conflict with
your statement above or are we talking two different topics? Or
perhaps you were referring to languages other than Haskell.
I was referring to Haskell. I believe the paper is referring to explicit memoization tied to the output from monads (i.e. where state is involved). I'm referring to the "automagic" memoization that the compiler & runtime do for you for the parts of your code that don't interact with monads (like this sort function).

"Automagic" memoization isn't really a function of a language at all, but rather the implementation. All a language can do is make it easier for the implementation to figure out when it can do it (which Haskell and C++ templates both do very well... but only one of them looks at all elegant ;-).

--Chris

--
KPLUG-LPSG@kernel-panic.org
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to