Eval
Posted: Sat Jul 30, 2011 3:01 am
So far I could replicate any macro by using (eval) in a function. I have to add quotes when I call the function though, but I feel like I've began to understand macros and now I am back at square 1. Could anyone give me an example of a macro where eval won't work?
e.g
I also had trouble creating a macro out of this since it expanded into a wrong form:
e.g
Code: Select all
(defmacro setvar-m (var value)
`(setf ,var ,value))
(defun setvar-f (var value)
(eval
`(setf ,var ,value)))
[3]> (setvar-m a 5)
5
(setvar-f 'v 7)
7
Code: Select all
(defun lvar (vlist)
(loop
for sub in vlist doing
(eval
`(setf ,(first sub) ,(second sub)))
(format t "~%~a : ~a~%" (first sub) (second sub))))