Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!CTCnet!news.math.psu.edu!chi-news.cic.net!newsfeed.internetmci.com!news.mathworks.com!fu-berlin.de!news.dfn.de!news.dkrz.de!news.rrz.uni-hamburg.de!news.Hanse.DE!wavehh.hanse.de!cracauer
From: cracauer@wavehh.hanse.de (Martin Cracauer)
Subject: Re: Functional Languages and Caches
Message-ID: <1996Mar22.205645.12160@wavehh.hanse.de>
Organization: BSD User Group Hamburg
References: <4iq667$nkv@csugrad.cs.vt.edu>
Date: Fri, 22 Mar 96 20:56:45 GMT
Lines: 44

jmaxwell@csugrad.cs.vt.edu (Jon A. Maxwell) writes:

>In a functional language supposedly there are no side-effects.

>I'm thinking that having a cache of function parameters and
>return values could speed up programs many times.  

I do not think that caching of function results violates functional
style. Although the function has state, the responces are not affected
by it.

Either Grahams 'On Lisp' or Norvig's Book has an example of a function
(or macro) that automaticaly generates functions with cache for Common
Lisp. I don't remember which book, sorry.

[...]

>If you were doing factorials, say you evaluated 5! + 4!.  After
>calculating 5!, the 4! would already be known and the answer
>could be returned without having to calculate it again.

This case wouldn't be covered by a simple cache that stores only the
latest result. 

[...]

>So would this cache be practical, and could it be used in a
>language such as lisp (which has side effects)?  I just wondering

See above, I remember the book's solution to be very elegant, a real
reason to use Lisp. I'm sure SML could have such a
function-modification function, too. I'm not sure about C++ :-)

>how they got emacs so fast.

?? I think a good Common Lisp compiler is much faster when modifing
byte arrays, although I didn't benchmark.

Happy Hacking
	Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@wavehh.hanse.de>  -  BSD User Group Hamburg
BSD, Lisp and other programming info http://www.bik-gmbh.de/~cracauer
