[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

setq with memory



I am a lisp beginner, so my question could have a straightforward answer.

I am trying to implement a simple function MY-SETQ which does exactly what 
SETQ does, and records in a list *MEM* the actions done. The objective is to 
have the possibility of seeing (and executing, by MAPCAR and EVAL) the 
assignements done.

I have implemented MY-SETQ as follows:

(defun my-setq (x y)
     (set x (eval y))
     (setq *MEM* (cons (list 'setq x y) *MEM*)))

After an inizialization of *MEM* to nil, the commands look like these:

(my-setq 'x ''abc)
(my-setq 'y ''(sin 1.2345))

and *MEM* is, in the above case: ((setq y '(sin 1.2345)) (setq x 'abc))

so that, for example, (mapcar 'eval *MEM*) does the required re-assignement.

The question is: how can I implement MY-SETQ such that the arguments are 
written in a more "natural" way, to say:  (my-setq  x  'abc) ?

Any suggestion will be greatly appreciated.






--------------------------------
Dr. Roberto Olmi
IROE-CNR
"Nello Carrara"
Via Panciatichi 64
50127 Firenze (Italy)
--------------------------------