Description: |
If you do not define a superclass for $class, then oo::object will be
the superclass of $class. This is explained in the documentation
(of oo::define) as "an empty parent class is equivalent to oo::object".
However, if you do oo::define $class { superclass }, then the superclass
slot is made empty, but does not again become equivalent to oo::object.
A crash can be caused. Example:
% oo::class create fruit {
method eat {} {
puts "yummy!"
}
}
::fruit
% set f [fruit new]
::oo::Obj12
% info object class $f oo::object
1
% info class superclasses fruit
::oo::object
% oo::define fruit { superclass }
% info class superclasses fruit
% info object class $f oo::object
0
% info object isa object $f
1
% $f destroy
impossible to invoke method "destroy": no defined method or unknown method
% info class call fruit destroy
cannot construct any call chain
% $f
Segmentation fault (core dumped)
-Marcel van der Goot
|