Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2013-08-02
15:00 • Closed ticket [9d61624b3d]: empty superclass slot is not always equivalent to oo... artifact: 9de2b95c92 user: dkf
14:58
[9d61624b3d]: Stop crashes when emptying the superclass slot. check-in: 8e643395a4 user: dkf tags: trunk
14:37 • Ticket [9d61624b3d] empty superclass slot is not always equivalent to oo::object... artifact: ce9ef918f7 user: dkf
2013-07-10
04:52 • Ticket [9d61624b3d]: 4 changes artifact: dbec366240 user: aku
2013-07-07
22:17 • New ticket [9d61624b3d]. artifact: 60227c02a4 user: anonymous

empty superclass slot is not always equivalent to oo::object

Closed / Fixed9d61624b3deb9fc676d69a59e0213e61cf8e5fb1Created 13 years agoUpdated 13 years ago
Descriptionplain2013-07-07 22:17:10
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
Referenced by1
aku Ticket [9d61624b3d]: 4 changes [History diff]2013-07-10 04:52:08
dkfwiki2013-08-02 14:37:40

Confirmed interactively. Ouch.

dkf Closed ticket [9d61624b3d]. [History diff]2013-08-02 15:00:08
Log in (anonymous is fine) to add a comment.