[e-lang] Looser memoization and constant-folding: will this work?

Kevin Reid kpreid at attglobal.net
Sat May 6 11:39:01 EDT 2006


When I wrote the memoizer for E-on-Common-Lisp (see  
org.cubik.cle.memoizeAuthor), I used these restrictions:

   - the wrapped object must be DeepFrozen
   - a call to it is only memoized if:
     - the arguments are DeepFrozen
     - the result is DeepPassByCopy

The result being DeepPassByCopy ensures that functions which return  
fresh results (e.g. any maker) each time don't return the same object  
under memoization.

I am at the moment trying to add compile-time evaluation of constant  
calls in the compiler, which is essentially the same problem.

There, it is a common occurrence that some DeepFrozen object returns  
another preexisting DeepFrozen object (for example, this call:  
(&__loop).getValue()), but in this case the result is not  
DeepPassByCopy.

It occurred to me that a simple fix would be to evaluate the call  
twice, and see whether the result object is different; since the  
call's parts are DeepFrozen, it can only be either always the same or  
always different.

Questions:

   - Is this correct?

   - Is there a way to handle the DeepFrozen-returns-DeepFrozen case  
which does not involve two possibly-arbitrarily-expensive evaluations?

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>




More information about the e-lang mailing list