Add standard anaphoric macros aif and awhen

This commit is contained in:
Renaud Casenave-Péré 2014-01-04 16:36:02 +09:00
parent 3c0b452d24
commit f6f7a8a512

View file

@ -7,13 +7,29 @@
(defpackage stoe.utils
(:use :cl)
(:nicknames :utils)
(:export :restartable
(:export :it
:aif
:awhen
:restartable
:eval-repl
:update-current-time :get-delta-time
:make-clock :clock-time :clock-delta
:update-clock :compare-clocks))
(in-package :stoe.utils)
(defmacro aif (test then else)
"Bind the result of evaluating `test' to a variable named `it', as per Paul Graham's On Lisp."
`(let ((it ,test))
(if it
,then
,else)))
(defmacro awhen (test &body body)
"Bind the result of evaluating `test' to a variable named `it', as per Paul Graham's On Lisp."
`(let ((it ,test))
(when it
,@body)))
(defmacro restartable (unprotected &body body)
"Provide a Continue restart unless unprotected is t."
`(if ,unprotected