Edit :never mind,it sort of is possible. Comments on code, will it work in every situation (i hope it does)
Code: Select all
(defmacro bind (functions &body body)
(let ((gen-vars (loop repeat (length functions) collecting (gensym))))
`(let ,(loop
for func in functions
for gen in gen-vars collecting `(,gen (symbol-function ',(first func))))
(unwind-protect
(progn
,@(loop for func in functions collecting
`(setf (symbol-function ',(first func))
,(second func)))
,@body)
(progn ,@(loop
for func in functions
for gen in gen-vars
collecting `(setf (symbol-function ',(first func))
,gen)))))))
(bind ((cl::print (lambda (arg) (format t "boom ~A" arg))))
(cl::print 'a))