Arrgh! AMOP and validate-superclass
Jacek Podkanski via Sbcl-help <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.general |
|---|---|
| Message-ID | <CAE9ibtp0Q7Kx9ZRXwNLKTg4xFcmJ5nZg9UXr3038Z62F0iZAqQ@mail.gmail.com> |
I was trying to experiment with type checking and tried to follow this advice: https://stackoverflow.com/questions/51723992/how-to-force-slots-type-to-be-checked-during-make-instance/56920918 All seemed to go well for classes that inherited from standard object. Problems started when I tried to inherit from another class. The errors did not make sense. Few people tried to explain dealing with the AMOP problems, and that did not make sense as well. To make matters worse I could not find any examples. In the end, using trial and error, I have something that works. I tried to create an object of the wrong class and got the expected error. So far so good. But can somebody please explain me why box is the supeclass in this context? Why does it work and did the error go away? (defclass/std coordinates () ((x :type integer) (y :type integer)) (:metaclass checked-class:checked-class)) (defclass/std size () ((x :type integer) (y :type integer)) (:metaclass checked-class:checked-class)) (defclass/std box (hrel) ((top-left :documentation "Relative Coordinates" :type coordinates) (width-height :documentation "Width and Height" :type size)) (:metaclass checked-class:checked-class)) ;;; add this to tell AMOP to allow type checking in classes that inherit from other than standard object (defmethod sb-mop:validate-superclass ((class checked-class:checked-class) (superclass box)) t) (defclass/std box-status (box) ((status :std nil)) (:metaclass checked-class:checked-class)) _______________________________________________ Sbcl-help mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sbcl-help