Guest User

Untitled

a guest
Apr 26th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #++
  2. (defun foo()
  3. (with-guards((print "fle closed!!!")
  4. (print "pipe closed!!!")
  5. (print "socket closed!!!"))
  6. (print "using")))
  7.  
  8. (defmacro with-guards((&rest guard*)&body body)
  9. (labels((rec(guard*)
  10. (if(endp guard*)
  11. (cons 'progn body)
  12. `(unwind-protect ,(rec(cdr guard*))
  13. ,(car guard*)))))
  14. (rec guard*)))
  15.  
  16. #| in REPL.
  17. * (foo)
  18.  
  19. "using"
  20. "socket closed!!!"
  21. "pipe closed!!!"
  22. "fle closed!!!"
  23. "using" ; <--- return value.
  24. |#
Add Comment
Please, Sign In to add comment