Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. (defclass animal ()
  2. ())
  3. (defclass bear (animal)
  4. ((height :initarg :height)))
  5. (defgeneric noise (animal))
  6. (defmethod noise ((animal bear))
  7. (format t "ROAR~%"))
  8. (defgeneric run (machine))
  9. (defgeneric does-not-understand (object message))
  10. (defmethod does-not-understand ((object bear) message)
  11. (format t "object ~s does not understand message ~s~%" object message))
  12. (defmethod no-applicable-method :around (gf &rest args)
  13. (format t "args: ~s~%" args)
  14. (format t "first: ~s~%" (first args))
  15. (format t "class-of: ~s~%" (class-of (first args)))
  16. (if (find-method #'does-not-understand nil (list (class-of (first args)) (find-class t)) nil)
  17. (apply #'does-not-understand (first args) (cons gf (rest args)))
  18. (call-next-method)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement