Can't redefine the class
hunar1997 opened this issue · comments
Why?
CL-USER> (defclass a () ())
#<standard-class A>
CL-USER> (defclass a () (name))
ERROR: Can't redefine the class named A.
Hm, I thought this was supported.
@vlad-km any insight about why this isn't supported yet and what would it take to add it?
https://github.com/jscl-project/jscl/blob/master/src/clos/std-object.lisp#L434-L436
This is the implementation of original CLOSETTE
as it is, with a little adaptation for JSCL.
The original CLOSETTE MOP
is as ancient as a mammoth. Methods that are later included in the standard are not provided for in it.
For this case it is the UPDATE-INSTANCE-FOR-REDEFINED-CLASS
method.
CLOS
for JSCL
needs to be rewritten -there are several pitfalls. But, if no one stepped on them in three years, this does not bother anyone :)
Oh that is very unfortunate.
Better than no having any clos at all at least. Thanks @vlad-km.
MOP
is rarely used in full, especially the exorcism of deleting
and redefining
classes.
In general, the closette mop
has a sufficiently complete and necessary set of basic methods to work.
What is missing is derived from the existing set of methods.
For the case above, the change-class
or update-instance-for-different-class
method is most suitable for some implementation.
Something like this 😸
I don't like the idea of allowing a class to be overridden.
But when debugging, this often has to be done.
A simple solution that can be done is to redefine the class descriptor with a new declaration.
In this case, the previously created instances will remain unchanged, and it will be necessary to override all existing methods with the new signature.
Perhaps a global variable will be added to allow such an override.
By default, this feature will remain disabled, ie. an already existing class is not overridden.
Will be:
(declaim (clos override)) ;; enable class redefinition
(declaim (closs non-override)) ;; disable redefinition, this is by default
When: asap