RosettaCodeData/Task/Polymorphic-copy/Common-Lisp/polymorphic-copy-1.lisp

13 lines
291 B
Common Lisp

(defstruct super foo)
(defstruct (sub (:include super)) bar)
(defgeneric frob (thing))
(defmethod frob ((super super))
(format t "~&Super has foo = ~w." (super-foo super)))
(defmethod frob ((sub sub))
(format t "~&Sub has foo = ~w, bar = ~w."
(sub-foo sub) (sub-bar sub)))