From: Stig H. <sti...@gm...> - 2016-01-04 08:49:28
|
If you are only dealing with constant expressions, Teemu Likonen's answer is correct. However, if you are actually constructing these expression on the fly, you will need to COMPILE them. (setf expr '(+ 1 2)) ;Actually the result of some complex calculation (setf a (compile nil expr)) (print (funcall a)) Alternatively, you can define a new function dynamically: (compile 'a expr) (print (a)) I hope I don't need to tell a C programmer that you only need to compile a function once to run it any number of times... Note that using COMPILE like this raises many of the same objections that EVAL does. Sometimes it is the thing to do, but usually there are better ways. Stig Hemmer |