[Openmcl-devel] compute values in place

Taoufik Dachraoui dachraoui.taoufik at gmail.com
Sun Sep 30 08:38:15 UTC 2012


Hi

I am writing a small interpreter for lambda calculus. Within an expression
I have some shared expressions

The following explains my need to compute a shared expression exactly once:

(let ((a '(#1=(+ 2 3) #1#)))
   (setf (first a) (compute (first a)))
   a)

-> I would like to see (#1=5 #1#)  == (5 5)

Is there a way to compute (+ 2 3) and set the result in the same memory
location of the expression

I tried the following:

(let ((a '(#1=(+ 2 3) #1#))) (setf (first a) (eval (first a))) a)
-> (5 (+ 2 3))

I want to avoid storing the expressions in a cons like:

(let ((a '(#1=(nil (+ 2 3)) #1#)))
   (setf (second (first a)) (eval (second (first a)))) a)
-> (#1=(NIL 5) #1#)

Kind regards
Taoufik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20120930/96a3b22e/attachment.html>


More information about the Openmcl-devel mailing list