Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defclass animal ()
- ())
- (defclass bear (animal)
- ((height :initarg :height)))
- (defgeneric noise (animal))
- (defmethod noise ((animal bear))
- (format t "ROAR~%"))
- (defgeneric run (machine))
- (defgeneric does-not-understand (object message))
- (defmethod does-not-understand ((object bear) message)
- (format t "object ~s does not understand message ~s~%" object message))
- (defmethod no-applicable-method :around (gf &rest args)
- (format t "args: ~s~%" args)
- (format t "first: ~s~%" (first args))
- (format t "class-of: ~s~%" (class-of (first args)))
- (if (find-method #'does-not-understand nil (list (class-of (first args)) (find-class t)) nil)
- (apply #'does-not-understand (first args) (cons gf (rest args)))
- (call-next-method)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement