Last active
March 21, 2019 00:53
-
-
Save fouric/595724587ecf6021ad4cfce4facf63dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment