[squeak-dev] Re: Recent MC doesn't support loading classes with
nil superclass?
Igor Stasenko
siguctua at gmail.com
Fri Sep 25 07:54:44 UTC 2009
2009/9/25 Julian Fitzell <jfitzell at gmail.com>:
> Not if you want portability... :)
>
> I was just struggling with this issue yesterday while porting Magritte
> to VAST, actually... I'm thinking of adding ProtoObject-like class to
> the compatibility layer that would need to have appropriate primitive
> methods added by each platform. And I think it will need to subclass
> nil...
>
Another thing about it, that MC package browser (if you click browse
the package without loading it) prints the class definition
incorrectly:
nil subclass: #BBBNameOfSubclass
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'NILSuperClass'
the problem is, that you can't evaluate it, because you'll get DNU.
While system browser prints class definition using 2 statements for a
class which having nil as superclass:
ProtoObject subclass: #BBBNameOfSubclass
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'NILSuperClass'.
BBBNameOfSubclass superclass: nil
Another little concern of mine, is that #superclass: implementation is
very dangerous one:
----------
superclass: aClass
"Change the receiver's superclass to be aClass."
"Note: Do not use 'aClass isKindOf: Behavior' here
in case we recompile from Behavior itself."
(aClass == nil or: [aClass isBehavior])
ifTrue: [superclass := aClass.
Object flushCache]
ifFalse: [self error: 'superclass must be a class-describing object']
----------
Suppose i got class A with 2 ivars, then i subclass it with class B
and add some other ivars, and then send
B superclass: nil.
At this point, it really should recompile everything. But as you can
see, there is no such check, and i fear to predict what could happen
if you start using instances of such class.
> Julian
>
--
Best regards,
Igor Stasenko AKA sig.
More information about the Squeak-dev
mailing list
|