(defmacro retrying (n &body body) (alexandria:with-gensyms (i) (alexandria:once-only (n) `(block out (dotimes (,i ,n) (block loop (handler-bind ((error (lambda (c) (declare (ignore c)) (return-from loop)))) ,@body (return-from out)))) (format t "Exceeded!"))))) (retrying (+ 1 2) (when (zerop (random 2)) (format t "Signaling an error!~%") (error "Error")) (format t "Hi!~%"))