bug in clsql MOP usage? -- change-MOP-class forbidden
"Hoehle, Joerg-Cyril" <[email protected]>
| Newsgroups | gmane.lisp.clsql.devel |
|---|---|
| Message-ID | <5F9130612D07074EB0A0CE7E69FD7A0302819349@S4DE8PSAAGS.blf.telekom.de> |
Hi,
it seems a paradox that while CLISP announces its full MOP support, cl-sql does not fully work with CLISP because of MOP issues.
It seems that cl-sql is doing something forbidden by the MOP, which CLISP catches while currently supported implementations don't.
cf clsql-3.0.8/tests/test-init.lisp:
CLSQL-USER[26]> (defclass thing ()
((extraterrestrial :initform nil :initarg :extraterrestrial)))
#<STANDARD-CLASS THING>
CLSQL-USER[29]> (def-view-class person (thing)
((height :db-kind :base :accessor height :type float
:initarg :height)
(married :db-kind :base :accessor married :type boolean
:initarg :married)
(birthday :type clsql:wall-time :initarg :birthday)
(bd-utime :type clsql:universal-time :initarg :bd-utime)
(hobby :db-kind :virtual :initarg :hobby :initform nil)))
*** - UPDATE-INSTANCE-FOR-DIFFERENT-CLASS: The MOP does not allow changing the
class of metaobject
#<CLSQL-SYS::VIEW-CLASS-EFFECTIVE-SLOT-DEFINITION EXTRATERRESTRIAL
#x2040F18E>
sql/metaclasses.lisp has a call to CHANGE-CLASS
(defmethod compute-effective-slot-definition ((class standard-db-class)
#+kmr-normal-cesd slot-name
direct-slots)
#+kmr-normal-cesd (declare (ignore slot-name))
(let ((dsd (car direct-slots)))
...
(let ((esd (call-next-method)))
...
(let ((type-predicate #+openmcl (slot-value esd 'ccl::type-predicate))\
)
#-openmcl (declare (ignore type-predicate))
(change-class esd 'view-class-effective-slot-definition
#+allegro :name
#+allegro (slot-definition-name dsd))
#+openmcl (setf (slot-value esd 'ccl::type-predicate)
type-predicate))
Here's what Bruno Haible (author of CLISP's MOP) said on this issue:
>Yes. There are four things that are not allowed with
>slot-definition objects:
>
> - Calling CHANGE-CLASS on them - explicitly forbidden,
> - Calling (SETF SLOT-DEFINTIION-xxx) on them - these setters are not
> specified by the MOP,
> - Calling (SETF (SLOT-VALUE ... 'xxx)) on them - the slot names are
> private and not specified by the MOP.
> - Overriding the generic functions SLOT-DEFINITION-xxx so as
>to return
> a different result that you compute from other parts of
>the slot-definition
> object - explicitly forbidden.
>
>In other words, once a slot-definition object is created, it's immutable,
>regarding the MOP specified accessors. (You can have mutable
>slots of your own, of course.)
>
>The only way to influence the creation of slot-definitions is
>therefore to
>use INITIALIZE-INSTANCE :AROUND methods on a particular subclass of
>STANDARD-SLOT-DEFINITION.
What would be a good way to resolve the issue?
It would be worthwhile if a) cl-sql worked with CLISP and b) it contains correct (or portable) code (if it's broken).
Regards,
Jörg Höhle.
Tested with cl-sql-3.0.8, CLISP from CVS and my independent implementation of UFFI for CLISP (see clisp patches section on sourceforge).