From b324caabfa2f0d04e2851a23f7e84dcd3fca5b9b Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Mon, 29 Nov 2004 11:07:54 +0000 Subject: [PATCH] 0.8.17.2: eager creation of CLOS classes for user defined structures * aka bug #331 --- BUGS | 6 ------ NEWS | 2 ++ src/pcl/braid.lisp | 10 ++++++---- tests/mop.impure.lisp | 7 +++++++ version.lisp-expr | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/BUGS b/BUGS index 48ca825..6252eed 100644 --- a/BUGS +++ b/BUGS @@ -1305,12 +1305,6 @@ WORKAROUND: in the wrapper, and then to update the instance just run through all the old wrappers in order from oldest to newest. -331: "lazy creation of CLOS classes for user-defined conditions" - (defstruct foo) - (defstruct (bar (:include foo))) - (sb-mop:class-direct-subclasses (find-class 'foo)) - returns NIL, rather than a singleton list containing the BAR class. - 332: "fasl stack inconsistency in structure redefinition" (reported by Tim Daly Jr sbcl-devel 2004-05-06) Even though structure redefinition is undefined by the standard, the diff --git a/NEWS b/NEWS index b091151..a86e5ba 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ changes in sbcl-0.8.18 relative to sbcl-0.8.17: * new feature: reloading changed shared object files with LOAD-SHARED-OBJECT now causes the new definitions to take effect. + * fixed bug #331: structure-class instances corresponding to + DEFSTRUCT forms are now created eagerly. changes in sbcl-0.8.17 relative to sbcl-0.8.16: * new feature: a build-time option (controlled by the :SB-UNICODE diff --git a/src/pcl/braid.lisp b/src/pcl/braid.lisp index 3b87419..ed76500 100644 --- a/src/pcl/braid.lisp +++ b/src/pcl/braid.lisp @@ -592,12 +592,14 @@ (t (error "~@<~S is not the name of a class.~@:>" name))))) -(defun maybe-reinitialize-structure-class (classoid) +(defun ensure-defstruct-class (classoid) (let ((class (classoid-pcl-class classoid))) - (when class - (ensure-non-standard-class (class-name class) class)))) + (cond (class + (ensure-non-standard-class (class-name class) class)) + ((eq 'complete *boot-state*) + (ensure-non-standard-class (classoid-name classoid)))))) -(pushnew 'maybe-reinitialize-structure-class sb-kernel::*defstruct-hooks*) +(pushnew 'ensure-defstruct-class sb-kernel::*defstruct-hooks*) (defun make-class-predicate (class name) (let* ((gf (ensure-generic-function name :lambda-list '(object))) diff --git a/tests/mop.impure.lisp b/tests/mop.impure.lisp index 0cdefc6..c510eb1 100644 --- a/tests/mop.impure.lisp +++ b/tests/mop.impure.lisp @@ -376,6 +376,13 @@ (defclass tomato () ()) (assert (null (sb-mop:class-direct-subclasses (find-class 'vegetable)))) +;;; bug 331: lazy creation of clos classes for defstructs +(defstruct bug-331-super) +(defstruct (bug-331-sub (:include bug-331-super))) +(let ((subs (sb-mop:class-direct-subclasses (find-class 'bug-331-super)))) + (assert (= 1 (length subs))) + (assert (eq (car subs) (find-class 'bug-331-sub)))) + ;;;; success (sb-ext:quit :unix-status 104) diff --git a/version.lisp-expr b/version.lisp-expr index 4951bfc..ca486d5 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.8.17.1" +"0.8.17.2" -- 1.7.10.4