Looping in a list is achieved with IN keyword, not FROM, which is numeric. And if you want to funcall by name then you need to quote your symbols, although I thought the point of this was to call the function directly? Also, indirect dependency on block name like this is bad style. And there are problems with variable capture. Something like this will work when used as a macroexpander function:
Code: Select all
(eval-when (:execute :compile-toplevel :load-toplevel)
(defconstant +functions+ '(1+ 1-)))
(defun compile-function (function block-name)
(let ((val (gensym)))
`((let ((,val (,function 4)))
(if (>= ,val 0)
,val
(return-from ,block-name -100))))))
(defun compile-functions (functions)
`(defun evaluate ()
(+ ,@(loop for function in functions
append (compile-function function 'evaluate)))))
On Lisp by Paul Graham explains a lot about macro programming, and it is available for free.