From: Nikodemus Siivola Date: Wed, 7 Jun 2006 09:58:37 +0000 (+0000) Subject: 0.9.13.32: restarts for slot-unbound X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=f06adcc6e3ce995dd9612de86355eebcc63bd0c6;p=sbcl.git 0.9.13.32: restarts for slot-unbound * USE-VALUE and STORE-VALUE have obvious meanings here, so use them. * Missing NEWS for .31. --- diff --git a/NEWS b/NEWS index 4a3386d..b688654 100644 --- a/NEWS +++ b/NEWS @@ -4,12 +4,16 @@ changes in sbcl-0.9.14 relative to sbcl-0.9.13: on OS X/x86. * feature: SBCL now tries to signal a STORAGE-CONDITION when running out of heap. + * feature: SBCL now provides USE-VALUE and STORE-VALUE restarts in the + default method for SLOT-UNBOUND. * minor incompatible change: prevent the user from specializing the new-value argument to SB-MOP:SLOT-VALUE-USING-CLASS. It's somewhat counter to the intent of the protocol, I (CSR) think, and additionally it just doesn't work in SBCL as currently implemented, thanks to optimizations (that are always valid for the other three SLOT-VALUEish functions, but not for the setter). + * bug fix: native unparsing of pathnames with :DIRECTORY NIL failed + with a type error. (reported by blitz_ on #lisp) * bug fix: unparsing logical pathnames with :NAME :WILD :TYPE NIL failed with a type error. (reported by Pascal Bourguignon) * bug fix: merging pathnames against defaults with :DIRECTORY diff --git a/package-data-list.lisp-expr b/package-data-list.lisp-expr index e92df2a..075589c 100644 --- a/package-data-list.lisp-expr +++ b/package-data-list.lisp-expr @@ -889,6 +889,7 @@ retained, possibly temporariliy, because it might be used internally." "NTH-BUT-WITH-SANE-ARG-ORDER" "DEPRECATION-WARNING" "BIT-VECTOR-=" + "READ-EVALUATED-FORM" ;; ..and macros.. "COLLECT" diff --git a/src/pcl/slots.lisp b/src/pcl/slots.lisp index 2e3d358..a37f983 100644 --- a/src/pcl/slots.lisp +++ b/src/pcl/slots.lisp @@ -318,7 +318,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 diff --git a/tests/clos.impure.lisp b/tests/clos.impure.lisp index c415f1a..d04a4c0 100644 --- a/tests/clos.impure.lisp +++ b/tests/clos.impure.lisp @@ -1267,5 +1267,18 @@ (list (find-class 'integer)))))) (assert (= (remove-method-1 3) 4)) (assert (= (remove-method-2 3) 2)) + +;;; ANSI doesn't require these restarts, but now that we have them we +;;; better test them too. +(defclass slot-unbound-restart-test () ((x))) +(let ((test (make-instance 'slot-unbound-restart-test))) + (assert (not (slot-boundp test 'x))) + (assert (= 42 (handler-bind ((unbound-slot (lambda (c) (use-value 42 c)))) + (slot-value test 'x)))) + (assert (not (slot-boundp test 'x))) + (assert (= 13 (handler-bind ((unbound-slot (lambda (c) (store-value 13 c)))) + (slot-value test 'x)))) + (assert (= 13 (slot-value test 'x)))) + ;;;; success diff --git a/version.lisp-expr b/version.lisp-expr index 1091375..e7667ef 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.9.13.31" +"0.9.13.32"