|
|
@ -39,6 +39,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
;;; --- actual (exported) code goes here --
|
|
|
|
;;; --- actual (exported) code goes here --
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro errors (stmt)
|
|
|
|
|
|
|
|
`(let ((ret (handler-case (cons ,stmt nil)
|
|
|
|
|
|
|
|
(t (c) (cons nil c)))))
|
|
|
|
|
|
|
|
(values (car ret) (cdr ret))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro try-catch (try &body catch)
|
|
|
|
|
|
|
|
(let ((errnm (gensym)))
|
|
|
|
|
|
|
|
`(let ((,errnm (handler-case (cons ,try nil)
|
|
|
|
|
|
|
|
(t (e)
|
|
|
|
|
|
|
|
(cons (progn ,@catch) e)))))
|
|
|
|
|
|
|
|
(if (cdr ,errnm)
|
|
|
|
|
|
|
|
(values (car ,errnm) (cdr ,errnm))
|
|
|
|
|
|
|
|
(values (car ,errnm) nil)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro try-catch-finally (try catch &body finally)
|
|
|
|
|
|
|
|
(let ((ret (gensym))
|
|
|
|
|
|
|
|
(err (gensym)))
|
|
|
|
|
|
|
|
`(multiple-value-bind (,ret ,err) (try-catch ,try ,catch)
|
|
|
|
|
|
|
|
(values (progn ,@finally) ,ret ,err))))
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro val-if-or (val test or)
|
|
|
|
(defmacro val-if-or (val test or)
|
|
|
|
"(if (test val) val or)"
|
|
|
|
"(if (test val) val or)"
|
|
|
|
`(let ((vv ,val))
|
|
|
|
`(let ((vv ,val))
|
|
|
|