Created
October 12, 2016 18:06
-
-
Save sjl/ae5c5813f1fa34ec0b5b5c7bb692883e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro let-bail (bindings &rest body) | |
(if (null bindings) | |
`(progn ,@body) | |
(destructuring-bind ((&whole binding symbol value &optional return-value) | |
&rest more-bindings) | |
bindings | |
(if (eql symbol 'bail-when) | |
`(if ,value ,return-value (let-bail ,more-bindings ,@body)) | |
`(let (,binding) (let-bail ,more-bindings ,@body)))))) | |
(let-bail ((x (random 100)) | |
(bail-when (oddp x) 'what) | |
(y (1+ x))) | |
(list x y)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment