Skip to content

Commit

Permalink
0.9.13.32: restarts for slot-unbound
Browse files Browse the repository at this point in the history
 * USE-VALUE and STORE-VALUE have obvious meanings here, so use them.
 * Missing NEWS for .31.
  • Loading branch information
nikodemus committed Jun 7, 2006
1 parent 85487ad commit f06adcc
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions package-data-list.lisp-expr
Expand Up @@ -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"
Expand Down
11 changes: 10 additions & 1 deletion src/pcl/slots.lisp
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tests/clos.impure.lisp
Expand Up @@ -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
2 changes: 1 addition & 1 deletion version.lisp-expr
Expand Up @@ -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"

0 comments on commit f06adcc

Please sign in to comment.