Hello Bob,
On Thu, May 1, 2008 at 5:52 PM, Robert Brown brown@google.com wrote:
I tried to get CLPython up and running on the latest SBCL. The diff below contains a couple of easy fixes. SBCL wants BREAK's argument to be a string and SBCL's LOOP does not like a negative loop increment.
Thanks for the patches!
The real porting problem right now is CLOS related. SBCL does not like the following code in core/classes.lisp:
;; Fix superclass and metaclass of PY-DICT. (ensure-class 'py-dict :direct-superclasses (list 'py-core-object) :metaclass 'py-core-type)
I get the following error:
debugger invoked on a SB-PCL::METAOBJECT-INITIALIZATION-VIOLATION in thread #<THREAD "initial thread" {11701A79}>: Cannot CHANGE-CLASS objects into CLASS metaobjects. See also: AMOP, Initialization of Class Metaobjects
I think the problem is that PY-DICT is a normal class and the ENSURE-CLASS call tries to turn it into a metaclass. Anyway, I'm far from a CLOS expert.
Well, class py-dict is not turned into a metaclass here, at least that's not the intention. :) The superclass and metaclass of it are changed but py-dict remains a non-metaclass class. So I think the actual error message is incorrect, but something else is wrong.
The problem might be that you can not change the metaclasses of a class using ensure-class. Could you please check if the call to ensure-class without the metaclass change is accepted?
(ensure-class 'py-dict :direct-superclasses (list 'py-core-object))
Thanks, - Willem
The call to ensure-class without
:metaclass 'py-core-type
succeeds.
The call with the :metaclass argument fails inside change-class:
(defmethod change-class ((instance standard-object) (new-class standard-class) &rest initargs) (unless (class-finalized-p new-class) (finalize-inheritance new-class)) (let ((cpl (class-precedence-list new-class))) (dolist (class cpl) (macrolet ((frob (class-name) `(when (eq class (find-class ',class-name)) (error 'metaobject-initialization-violation :format-control "~@<Cannot ~S objects into ~S metaobjects.~@:>" :format-arguments (list 'change-class ',class-name) :references (list '(:amop :initialization ,class-name)))))) (frob class) (frob generic-function) (frob method) (frob slot-definition)))) (change-class-internal instance new-class initargs))
CLASS is on the class precedence list of PY-CORE-TYPE.
bob
====================
Willem Broekema writes:
Hello Bob,
On Thu, May 1, 2008 at 5:52 PM, Robert Brown brown@google.com wrote:
I tried to get CLPython up and running on the latest SBCL. The diff below contains a couple of easy fixes. SBCL wants BREAK's argument to be a string and SBCL's LOOP does not like a negative loop increment.
Thanks for the patches!
The real porting problem right now is CLOS related. SBCL does not like the following code in core/classes.lisp:
;; Fix superclass and metaclass of PY-DICT. (ensure-class 'py-dict :direct-superclasses (list 'py-core-object) :metaclass 'py-core-type)
I get the following error:
debugger invoked on a SB-PCL::METAOBJECT-INITIALIZATION-VIOLATION in thread #<THREAD "initial thread" {11701A79}>: Cannot CHANGE-CLASS objects into CLASS metaobjects. See also: AMOP, Initialization of Class Metaobjects
I think the problem is that PY-DICT is a normal class and the ENSURE-CLASS call tries to turn it into a metaclass. Anyway, I'm far from a CLOS expert.
Well, class py-dict is not turned into a metaclass here, at least that's not the intention. :) The superclass and metaclass of it are changed but py-dict remains a non-metaclass class. So I think the actual error message is incorrect, but something else is wrong.
The problem might be that you can not change the metaclasses of a class using ensure-class. Could you please check if the call to ensure-class without the metaclass change is accepted?
(ensure-class 'py-dict :direct-superclasses (list 'py-core-object))
Thanks,
- Willem
On Thu, May 1, 2008 at 7:30 PM, Robert Brown brown@google.com wrote:
The call to ensure-class without
:metaclass 'py-core-type
succeeds.
The call with the :metaclass argument fails inside change-class:
(defmethod change-class ((instance standard-object) (new-class standard-class) &rest initargs) (unless (class-finalized-p new-class) (finalize-inheritance new-class)) (let ((cpl (class-precedence-list new-class))) (dolist (class cpl) (macrolet ((frob (class-name) `(when (eq class (find-class ',class-name)) (error 'metaobject-initialization-violation :format-control "~@<Cannot ~S objects into ~S metaobjects.~@:>" :format-arguments (list 'change-class ',class-name) :references (list '(:amop :initialization ,class-name)))))) (frob class) (frob generic-function) (frob method) (frob slot-definition)))) (change-class-internal instance new-class initargs))
CLASS is on the class precedence list of PY-CORE-TYPE.
Thanks, I'm going to look into this.
- Willem
On Thu, May 1, 2008 at 9:55 PM, Willem Broekema metawilm@gmail.com wrote:
Thanks, I'm going to look into this.
Now the class bootstrapping is rewritten, so no need for such a class redefinition anymore. Please give it a try. (On my SBCL 1.0.10 for Mac OS X 10.4, it fails with a strange "no suitable method for STREAM-ELEMENT-TYPE", which is said to be fixed in a later version.) The change should be in public CVS in an hour. Lispworks and Allegro still run the test suite fine.
- Willem
clpython-devel@common-lisp.net