Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!newsfeed.internetmci.com!in1.uu.net!netnews.jhuapl.edu!aplcenmp!hall
From: hall@aplcenmp.apl.jhu.edu (Marty Hall)
Subject: Re: Functional Languages and Caches
Message-ID: <DottEx.287@aplcenmp.apl.jhu.edu>
Organization: JHU/APL Research Center, Hopkins P/T CS Faculty
References: <4iq667$nkv@csugrad.cs.vt.edu> <1996Mar22.205645.12160@wavehh.hanse.de>
Date: Mon, 25 Mar 1996 13:56:57 GMT
Lines: 27

In article <1996Mar22.205645.12160@wavehh.hanse.de>
cracauer@wavehh.hanse.de (Martin Cracauer) writes: 
[... Memoization in Common Lisp ...]
> I'm sure SML could have such a
>function-modification function, too. I'm not sure about C++ :-)

Surprisingly, it is not so easy to do this in SML at runtime. Creating
a function that returns a caching version of an input function can be
tricky since you have to know a lot about types. However, the real
problem is that SML uses static binding to associate function objects
with function (variable) names. So even if you could make a memoizing
version of your function and assigned it back to the original function
(variable) name, previous references would get the old function, not
the new one.

Paul McNamee (paul_mcnamee@jhuapl.edu) and I are working on a version
in C++ that uses a preprocessor to do the conversion at (before)
compile time instead of at runtime. This limits some of the useful
things you can do in Common Lisp versions of memoization, but still
seems quite useful.

An early paper on our Common Lisp memoization package and a link to
the source code is available from my Lisp Tutorial page at
http://www.apl.jhu.edu/~hall/lisp.html.

						- Marty
(proclaim '(inline skates))
