Skip to content

Instantly share code, notes, and snippets.

@psyomn
Last active December 29, 2015 05:19
Show Gist options
  • Select an option

  • Save psyomn/7621469 to your computer and use it in GitHub Desktop.

Select an option

Save psyomn/7621469 to your computer and use it in GitHub Desktop.
defmethod without classes
#!/usr/bin/sbcl --script
;;
;; You don't really need to supply a class literal to use methods,
;; this way you can exploid the :before, :after, :around auxiliary
;; methods!
;;
(defmethod myfunc (lst)
(format t "~A~%" lst))
(defmethod myfunc :before (lst)
(format t "Y HALLO THERE~%"))
(defmethod myfunc :after (lst)
(format t "Interesting thing you saw~%"))
(defmethod i-never-run (lst)
(format t "and i feel terrible about it. I need to become fit again~%"))
(defmethod i-never-run :around (lst)
(format t "~A~A~%" "i run everyday every week every month every year. "
"Check out my massive legs!"))
(myfunc '(1 2 3 4 5))
(i-never-run '(1 2 3))
;; Output
;;
;; Y HALLO THERE
;; (1 2 3 4 5)
;; Interesting thing you saw
;; i run everyday every week every month every year. Check out my massive legs!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment