Created
April 18, 2018 17:29
-
-
Save hyotang666/4469845cf8e6c52eb4b2a0492397e340 to your computer and use it in GitHub Desktop.
This file contains 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
#++ | |
(defun foo() | |
(with-guards((print "fle closed!!!") | |
(print "pipe closed!!!") | |
(print "socket closed!!!")) | |
(print "using"))) | |
(defmacro with-guards((&rest guard*)&body body) | |
(labels((rec(guard*) | |
(if(endp guard*) | |
(cons 'progn body) | |
`(unwind-protect ,(rec(cdr guard*)) | |
,(car guard*))))) | |
(rec guard*))) | |
#| in REPL. | |
* (foo) | |
"using" | |
"socket closed!!!" | |
"pipe closed!!!" | |
"fle closed!!!" | |
"using" ; <--- return value. | |
|# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment