On 6/27/07, Christopher Smith <[EMAIL PROTECTED]> wrote:
On Jun 27, 2007, at 10:03 AM, Bob La Quey wrote:
> A key issue  wrt speed is  caching.  Never compute something twice.
> Functional programming makes caching of results much easier. Same
> arguments => same result => use the cache.

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).

--Chris

Strange coincidence: I'm reading a paper on natural language parsing
today and the authors happen to use Haskell.[1] For those of you that
wanted more comments, you may find it interesting that the authors
went the "literate programming" route and that the source for the
paper contains the program itself.

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.

Also, I love this comment in the code:
-- This version of the program has been tested using Hugs.  Two small changes
-- are required to run this code with Gofer; search for the string Gofer in
-- two places in the main text, and follow the instructions that you find.
Because it brought back memories of punching in BASIC programs from
magazines back in the '80s. ("This is for a C-64. If you are on a
TRS-80 change lines 140-180 to...)

[1] http://web.cecs.pdx.edu/~mpj/pubs/aug.html


-Chuck

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to