SHARE
TWEET

Untitled

a guest Mar 26th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top