From: Christophe Rhodes Date: Sun, 28 May 2006 11:02:02 +0000 (+0000) Subject: 0.9.13.4: X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=e404d36bb823d93ad20ccd6c653244cf443f2633;p=sbcl.git 0.9.13.4: Explicitly disallow specializations on new-value for (setf slot-value-using-class), as suggested by Levente Mezaros sbcl-devel 2006-05-09. ... documentation ... internals documentation ... also one or two other small cleanups: don't keep dfun information in special-case generic functions; make metaobject-protocol-violation an error, not just a condition. --- diff --git a/NEWS b/NEWS index f97afdb..7994058 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,11 @@ ;;;; -*- coding: utf-8; -*- changes in sbcl-0.9.14 relative to sbcl-0.9.13: + * 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: unparsing logical pathnames with :NAME :WILD :TYPE NIL failed with a type error. (reported by Pascal Bourguignon) * fixed some bugs revealed by Paul Dietz' test suite: diff --git a/doc/internals/slot-value.texinfo b/doc/internals/slot-value.texinfo index 0a00d8f..ec0312f 100644 --- a/doc/internals/slot-value.texinfo +++ b/doc/internals/slot-value.texinfo @@ -189,3 +189,7 @@ computed lazily rather than eagerly. The default image has 8589 closures implementing this optimization: 3 (@code{slot-value}, @code{set-slot-value} and @code{slot-boundp}) for each of 2863 effective slots.) + +(Also note that this optimization depends on not being able to +specialize the @code{new-value} argument to @{(setf +slot-value-using-class)}.) diff --git a/doc/manual/beyond-ansi.texinfo b/doc/manual/beyond-ansi.texinfo index 7a79357..93929ec 100644 --- a/doc/manual/beyond-ansi.texinfo +++ b/doc/manual/beyond-ansi.texinfo @@ -132,6 +132,30 @@ Common Lisp restriction on defining functions, variables and types named by symbols in the Common Lisp package: preventing two independent pieces of software from colliding with each other. +@item +@findex slot-value-using-class +@findex sb-mop:slot-value-using-class +@findex (setf slot-value-using-class) +@findex (setf sb-mop:slot-value-using-class) +@findex slot-boundp-using-class +@findex sb-mop:slot-boundp-using-class +specializations of the @code{new-value} argument to @code{(setf +sb-mop:slot-value-using-class)} are not allowed: all user-defined +methods must have a specializer of the class @code{t}. + +This prohibition is motivated by a separation of layers: the +@code{slot-value-using-class} family of functions is intended for use in +implementing different and new slot allocation strategies, rather than +in performing application-level dispatching. Additionally, with this +requirement, there is a one-to-one mapping between metaclass, class and +slot-definition-class tuples and effective methods of @code{(setf +slot-value-using-class)}, which permits optimization of @code{(setf +slot-value-using-class)}'s discriminating function in the same manner as +for @code{slot-value-using-class} and @code{slot-boundp-using-class}. + +Note that application code may specialize on the @code{new-value} +argument of slot accessors. + @end itemize @node Support For Unix diff --git a/src/pcl/methods.lisp b/src/pcl/methods.lisp index 9f43c63..f61386e 100644 --- a/src/pcl/methods.lisp +++ b/src/pcl/methods.lisp @@ -54,7 +54,7 @@ ;;; Methods are not reinitializable. (define-condition metaobject-initialization-violation - (reference-condition simple-condition) + (reference-condition simple-error) ()) (macrolet ((def (name args control) @@ -486,6 +486,18 @@ (loop (when (null methods) (return gf)) (real-add-method gf (pop methods) methods))) +(define-condition new-value-specialization (reference-condition error) + ((%method :initarg :method :reader new-value-specialization-method)) + (:report + (lambda (c s) + (format s "~@" + (new-value-specialization-method c) + #'(setf slot-value-using-class)))) + (:default-initargs :references + (list '(:sbcl :node "Metaobject Protocol") + '(:amop :generic-function (setf slot-value-using-class))))) + (defun real-add-method (generic-function method &optional skip-dfun-update-p) (when (method-generic-function method) (error "~@