Fix 14 wave-4 re-review findings (batches w4a+w4b)

This commit is contained in:
venomade committed 2026-11-22 12:23:01 +00:00
1 parent a28a35991f
commit fd5e11cdeb
23 files changed
+98 -29

No files matched your search

+3
View File
@@ -5,3 +5,6 @@ Classes, instances, generic dispatch, and method combination.
DEFGENERIC names an operation; DEFMETHOD implements it, once per
class. :BEFORE and :AFTER methods combine around the primary one,
and (EQL x) specializers dispatch on a single value.
WITH-SLOTS and WITH-ACCESSORS read a whole object at a glance,
CALL-NEXT-METHOD stands on the method above, and PRINT-OBJECT with
:DEFAULT-INITARGS shape how objects print and build.
+6 -2
View File
@@ -29,8 +29,12 @@
;;; them unchanged.
;;; ------------------------------------------------------------------
(check (let ((q (double-point (make-instance 'point :x 3 :y 4))))
(and (eql 6 (point-x q)) (eql 8 (point-y q)))))
(check (let* ((p (make-instance 'point :x 3 :y 4))
(q (double-point p)))
(and (not (eq q p))
(eql 3 (point-x p))
(eql 6 (point-x q))
(eql 8 (point-y q)))))
(check (let ((p (shift-x (make-instance 'point :x 1))))
(eql 2 (point-x p))))
(check (let ((p (shift-x (make-instance 'point :x 10))))
+12 -2
View File
@@ -19,14 +19,23 @@
(defgeneric purr (a))
(defmethod purr ((a animal))
"prrr-from-animal")
(defgeneric hiss (a))
;; TODO: A DOG announces what an animal announces, then adds
;; " Woof!".
(defmethod announce ((d dog))
"Woof!")
;; TODO: CAT purrs: if a method above you exists, use its answer;
;; otherwise say "Prrr".
;; otherwise say "Prrr" - and CAT hisses the same way, though HISS
;; has no method above CAT at all.
(defmethod purr ((c cat))
"Prrr")
(defmethod hiss ((c cat))
(call-next-method))
;;; ------------------------------------------------------------------
@@ -36,4 +45,5 @@
(check-equal "I am an animal. Woof!" (announce (make-instance 'dog)))
(check-equal "I am an animal." (announce (make-instance 'animal)))
(check-equal "Prrr" (purr (make-instance 'cat)))
(check-equal "prrr-from-animal" (purr (make-instance 'cat)))
(check-equal "Prrr" (hiss (make-instance 'cat)))