Plaster
New
List
Login
text
default
anonymous
2024.09.27 01:16:35
(defclass point () ((%x :initarg :x :reader x) (%y :initarg :y :reader y) (%z :initarg :z :reader z)) (:default-initargs :x nil :y nil :z nil)) (defun point (&key x y z) (make-instance 'point :x x :y y :z z)) (defmethod print-object ((point point) stream) (let* ((x (x point)) (y (y point)) (z (z point)) (form `(point ,@(if (null x) '() `(:x ,x)) ,@(if (null y) '() `(:y ,y)) ,@(if (null z) '() `(:z ,z))))) (prin1 form stream) ;; Or this? #+(or) (format stream "#.~S" form)) point) (defclass point* (point) ()) (defmethod print-object ((point point*) stream) (let* ((x (x point)) (y (y point)) (z (z point)) (form `(make-instance 'point* ,@(if (null x) '() `(:x ,x)) ,@(if (null y) '() `(:y ,y)) ,@(if (null z) '() `(:z ,z))))) (prin1 form stream) ;; Or this? #+(or) (format stream "#.~S" form)) point)
Raw
Annotate
Repaste
Edit