X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fpcl%2Fslots.lisp;h=1b1326be3792057048474ac7b365d118987a8e77;hb=5fc1ec5b716d89f5018bc159a88f82cb2077b7e6;hp=2e3d35817f092184a3e3ca059fa732cee7fc6748;hpb=444d2072bc52e60a41af62ee22e343e76109212f;p=sbcl.git diff --git a/src/pcl/slots.lisp b/src/pcl/slots.lisp index 2e3d358..1b1326b 100644 --- a/src/pcl/slots.lisp +++ b/src/pcl/slots.lisp @@ -136,9 +136,12 @@ (let ((class (class-of object))) (not (null (find-slot-definition class slot-name))))) +(defvar *unbound-slot-value-marker* (make-unprintable-object "unbound slot")) + ;;; This isn't documented, but is used within PCL in a number of print ;;; object methods. (See NAMED-OBJECT-PRINT-FUNCTION.) -(defun slot-value-or-default (object slot-name &optional (default "unbound")) +(defun slot-value-or-default (object slot-name &optional + (default *unbound-slot-value-marker*)) (if (slot-boundp object slot-name) (slot-value object slot-name) default)) @@ -318,7 +321,16 @@ instance)) (defmethod slot-unbound ((class t) instance slot-name) - (error 'unbound-slot :name slot-name :instance instance)) + (restart-case + (error 'unbound-slot :name slot-name :instance instance) + (use-value (v) + :report "Return a value as the slot-value." + :interactive read-evaluated-form + v) + (store-value (v) + :report "Store and return a value as the slot-value." + :interactive read-evaluated-form + (setf (slot-value instance slot-name) v)))) (defun slot-unbound-internal (instance position) (values