(uiop:define-package :solar-short/class (:export #:book #:display-haiku #:next-haiku) (:import-from :asdf)) (in-package :solar-short/class) (defclass book () ((haikus :initform (list "haiku 1" "haiku 2" "haiku 3")) (current :initform 0))) (defmethod display-haiku ((obj book) stream) (with-slots (haikus current) obj (format *standard-output* "haiku num: ~a" current) (princ (nth current haikus) stream))) (defmethod next-haiku ((obj book)) (with-slots (haikus current) obj (format *standard-output* "increasing current") (let ((factor (if (= current (length haikus)) 0 1))) (format *standard-output* "increment factor: ~a" factor) (finish-output *standard-output*) (setf current (+ factor current)))))