[armedbear-devel] Unbound initargs slot in slot-definitions

Having two classes: (defclass slot-d-1 (mop:standard-direct-slot-definition) ()) (defclass slot-d-2 (mop:standard-direct-slot-definition) (a)) (slot-boundp (make-instance 'slot-d-2) 'sys::initargs) => T (slot-boundp (make-instance 'slot-d-2) 'sys::initargs) => NIL So, having a slot makes initargs unbound. Below is the actual code which suffers from it: (defpackage test (:use :cl :mop)) (in-package test) (defclass storable-class (standard-class) ()) (defmethod validate-superclass ((class standard-class) (superclass storable-class)) t) (defmethod validate-superclass ((class storable-class) (superclass standard-class)) t) (defclass storable-direct-slot-definition (standard-direct-slot-definition) ((storep :initarg :storep :initform t :reader store-slot-p))) (defmethod direct-slot-definition-class ((class storable-class) &key) (find-class 'storable-direct-slot-definition)) ;;; (defclass identifiable () ((id :accessor id :initform nil :storep nil)) (:metaclass storable-class)) The last form receives an error: The slot INITARGS is unbound in the object #<STORABLE-DIRECT-SLOT-DEFINITION {34C1EFE7}>. -- With best regards, Stas.

On Aug 13, 2012, at 22:43, Stas Boukarev <stassats@gmail.com> wrote:
Having two classes: (defclass slot-d-1 (mop:standard-direct-slot-definition) ()) (defclass slot-d-2 (mop:standard-direct-slot-definition) (a))
(slot-boundp (make-instance 'slot-d-2) 'sys::initargs) => T
(slot-boundp (make-instance 'slot-d-2) 'sys::initargs) => NIL
So, having a slot makes initargs unbound.
Hmm, I wonder whether this comment in SlotDefinitionClass.java: /** * For internal use only. This constructor hardcodes the layout of the class, and can't be used * to create arbitrary subclasses of slot-definition. */ has anything to do with it. Need to do some thinking and code reading on this one. Rudi

Hi Stas, This should be fixed in r14134, together with a bug reported by Pascal Costanza. Thanks, Rudi On Aug 13, 2012, at 22:43, Stas Boukarev <stassats@gmail.com> wrote:
Having two classes: (defclass slot-d-1 (mop:standard-direct-slot-definition) ()) (defclass slot-d-2 (mop:standard-direct-slot-definition) (a))
(slot-boundp (make-instance 'slot-d-2) 'sys::initargs) => T
(slot-boundp (make-instance 'slot-d-2) 'sys::initargs) => NIL
So, having a slot makes initargs unbound.
Below is the actual code which suffers from it:
(defpackage test (:use :cl :mop))
(in-package test)
(defclass storable-class (standard-class) ())
(defmethod validate-superclass ((class standard-class) (superclass storable-class)) t)
(defmethod validate-superclass ((class storable-class) (superclass standard-class)) t)
(defclass storable-direct-slot-definition (standard-direct-slot-definition) ((storep :initarg :storep :initform t :reader store-slot-p)))
(defmethod direct-slot-definition-class ((class storable-class) &key) (find-class 'storable-direct-slot-definition))
;;;
(defclass identifiable () ((id :accessor id :initform nil :storep nil)) (:metaclass storable-class))
The last form receives an error:
The slot INITARGS is unbound in the object #<STORABLE-DIRECT-SLOT-DEFINITION {34C1EFE7}>.
-- With best regards, Stas.
_______________________________________________ armedbear-devel mailing list armedbear-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel

Rudolf Schlatte <rudi@constantly.at> writes:
Hi Stas,
This should be fixed in r14134, together with a bug reported by Pascal Costanza.
Yay, now my object storage can be compiled and is working for loading data! (Saving doesn't produce the same result, I'll look why later.) -- With best regards, Stas.

Stas Boukarev <stassats@gmail.com> writes:
Rudolf Schlatte <rudi@constantly.at> writes:
Hi Stas,
This should be fixed in r14134, together with a bug reported by Pascal Costanza.
Yay, now my object storage can be compiled and is working for loading data! (Saving doesn't produce the same result, I'll look why later.) Ok, that was because ABCL puts inherited slots at the end and other implementations put them in the beginning. Fixed it by sorting the slots beforehand.
(defclass foo () (a b c)) (defclass bar (foo) (d e f)) class-slots of bar becomes (D E F A B C), while everywhere else it's (A B C D E F). Now, that's not a big issue and MOP allows it, but it'd be nice for the sake of consistency when debugging or using an inspector to have them in the same order. -- With best regards, Stas.

On Aug 26, 2012, at 15:31, Stas Boukarev <stassats@gmail.com> wrote:
Ok, that was because ABCL puts inherited slots at the end and other implementations put them in the beginning. Fixed it by sorting the slots beforehand.
(defclass foo () (a b c))
(defclass bar (foo) (d e f)) class-slots of bar becomes (D E F A B C), while everywhere else it's (A B C D E F).
Now, that's not a big issue and MOP allows it, but it'd be nice for the sake of consistency when debugging or using an inspector to have them in the same order.
This should be fixed now. I'm having a slight fever today, but ansi-tests don't report new failures (in contrast to my first attempt), so I hope I didn't break anything. Rudi

Rudolf Schlatte <rudi@constantly.at> writes:
Hi Stas,
This should be fixed in r14134, together with a bug reported by Pascal Costanza.
Now another problem, almost the same code, except for slot definitions: (defpackage test2 (:use :cl :mop)) (in-package test2) (defclass storable-class (standard-class) ()) (defmethod validate-superclass ((class standard-class) (superclass storable-class)) t) (defmethod validate-superclass ((class storable-class) (superclass standard-class)) t) ;;; (defclass identifiable () ((id :accessor id :initform 1)) (:metaclass storable-class)) Now ID slot is unbound and bound at the same time, despite having an initform. (describe (make-instance 'identifiable)) #<IDENTIFIABLE {181F4B24}> is an instance of #<STORABLE-CLASS IDENTIFIABLE {1E4B2D10}>. The following slots have :INSTANCE allocation: ID unbound (slot-boundp (make-instance 'identifiable) 'id) => NIL (slot-value (make-instance 'identifiable) 'id) => 1 -- With best regards, Stas.
participants (2)
-
Rudolf Schlatte
-
Stas Boukarev