0.9.16.11:
authorChristophe Rhodes <csr21@cam.ac.uk>
Fri, 1 Sep 2006 15:32:21 +0000 (15:32 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Fri, 1 Sep 2006 15:32:21 +0000 (15:32 +0000)
Give funcallable-standard-object the direct superclasses
(function standard-object), to make generic-function have a
superclass list in accord with CLHS 1.4.4.5.  This deviation
from AMOP is compatible with Lispworks and CLISP.

NEWS
doc/manual/beyond-ansi.texinfo
src/pcl/defs.lisp
tests/clos.pure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 033fc69..1fed6a0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,12 @@ changes in sbcl-0.9.17 (0.9.99?) relative to sbcl-0.9.16:
     following unused symbols: *GC-NOTIFY-AFTER*, *GC-NOTIFY-BEFORE*,
     *GC-NOTIFY-STREAM*, *ERROR-PRINT-LENGTH*, *ERROR-PRINT-LEVEL*,
     *ERROR-PRINT-LINES*
+  * minor incompatible change: the direct superclasses of
+    SB-MOP:FUNCALLABLE-STANDARD-OBJECT are (FUNCTION STANDARD-OBJECT),
+    not (STANDARD-OBJECT FUNCTION).  This makes the
+    class-precedence-lists of GENERIC-FUNCTION and
+    STANDARD-GENERIC-FUNCTION comply with the requirement of ANSI
+    1.4.4.5.
   * bug fix: ENOUGH-NAMESTRING on pathnames with no name and a pattern
     for a type now works.
   * bug fix: loading of default sysinit file works. (thanks to Leonid
index bbddfd5..2fc20c8 100644 (file)
@@ -51,6 +51,22 @@ are:
 
 There is no record of what the second return value was meant to
 indicate, and apparently no clients for it.
+
+@item
+@tindex generic-function
+@tindex standard-generic-function
+@tindex funcallable-standard-object
+@tindex sb-mop:funcallable-standard-object
+@tindex standard-object
+@tindex function
+The direct superclasses of @code{sb-mop:funcallable-standard-object} are
+@code{(function standard-object)}, not @code{(standard-object function)}.
+
+This is to ensure that the @code{standard-object} class is the last of
+the standardized classes before @code{t} appearing in the class
+precedence list of @code{generic-function} and
+@code{standard-generic-function}, as required by section 1.4.4.5 of the
+ANSI specification.
   
 @item
 @findex ensure-generic-function
@@ -76,9 +92,9 @@ Where AMOP specifies @code{:declarations} as the keyword argument to
 @tindex function
 @findex sb-mop:class-prototype
 @findex class-prototype
-although SBCL obeys the requirement in AMOP for
-@code{validate-superclass} for @code{standard-class} and
-@code{funcallable-standard-class} to be compatible metaclasses, we
+although SBCL obeys the requirement in AMOP that
+@code{validate-superclass} should treat @code{standard-class} and
+@code{funcallable-standard-class} as compatible metaclasses, we
 impose an additional requirement at class finalization time: a class
 of metaclass @code{funcallable-standard-class} must have
 @code{function} in its superclasses, and a class of metaclass
@@ -87,14 +103,14 @@ of metaclass @code{funcallable-standard-class} must have
 @findex typep
 @findex class-of
 @findex subtypep
-At class finalization, a class prototype which is accessible by a
-standard mop function @code{sb-mop:class-prototype}.  The user can
-then ask whether this object is a @code{function} or not in several
-different ways: whether it is a function according to @code{typep};
-whether its @code{class-of} is @code{subtypep} @code{function}, or
-whether @code{function} appears in the superclasses of the class.  The
-additional consistency requirement comes from the desire to make all
-of these answers the same.
+After a class has been finalized, it is associated with a class
+prototype which is accessible by a standard mop function
+@code{sb-mop:class-prototype}.  The user can then ask whether this
+object is a @code{function} or not in several different ways: whether it
+is a function according to @code{typep}; whether its @code{class-of} is
+@code{subtypep} @code{function}, or whether @code{function} appears in
+the superclasses of the class.  The additional consistency requirement
+comes from the desire to make all of these answers the same.
 
 The following class definitions are bad, and will lead to errors
 either immediately or if an instance is created:
index 68e53b6..6cd5a77 100644 (file)
 
 (defclass standard-object (slot-object) ())
 
-(defclass funcallable-standard-object (standard-object function)
+(defclass funcallable-standard-object (function standard-object)
   ()
   (:metaclass funcallable-standard-class))
 
index 425a0b2..803b48a 100644 (file)
 
 ;;; this one's user-observable
 (assert (typep #'(setf class-name) 'generic-function))
+
+;;; CLHS 1.4.4.5.  We could test for this by defining methods
+;;; (i.e. portably) but it's much easier using the MOP and
+;;; MAP-ALL-CLASSES.
+(flet ((standardized-class-p (c)
+         (find-symbol (symbol-name (class-name c)) "CL")))
+  (let (result)
+    (sb-pcl::map-all-classes
+     (lambda (c) (when (standardized-class-p c)
+                   (let* ((cpl (sb-mop:class-precedence-list c))
+                          (std (position (find-class 'standard-object) cpl))
+                          (str (position (find-class 'structure-object) cpl))
+                          (last (position-if
+                                 #'standardized-class-p (butlast cpl)
+                                 :from-end t)))
+                     (when (and std str)
+                       (push `(:and ,c) result))
+                     (when (and str (< str last))
+                       (push `(:str ,c) result))
+                     (when (and std (< std last))
+                       (push `(:std ,c) result))))))
+    (assert (null result))))
index 8bfe9d3..6e9fa42 100644 (file)
@@ -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.16.10"
+"0.9.16.11"