Class Initialization
ducasse
ducasse at iam.unibe.ch
Tue Mar 9 21:29:00 UTC 2004
On 9 mars 04, at 21:46, Frank Caggiano wrote:
> It's been a long time since I worked with any other Smalltalk other
> than Squeak and the following class initialization situation has me
> confused.
>
> If a class has a class method 'initialize' when that class is loaded
> into the system either as a filed in cs, or .st file or if it is
> loaded via monticello the initialize method is run.
>
> Question: Is this normal smalltalk behavior or is squeak specific? The
> literature is fuzzy on class initialization.
No it is Smalltalk specific. After each packaging system introduce also
its own hooks.
>
> Now lets say you have two classes A and B with B being a subclass of A.
> A has a class initialize method, B also has a class initialize method
> and being a subclass of A it was thought that a super initialize was
> needed in B to get A to initialize. What happens in this case is that
> A's initialize gets run twice.
You should never call a super in the class initialize because it will o
up the hierarchy and initialize stuff in Object you do not want
such as DependentFields
>
> Question: How should this situation be handled? Should B just assume
> that if A is in the system (and it must be if B is A's subclass and B
> is loaded, correct) that A is initialized and not worry about it?
This is the responsibility of a class to be loaded and well initialized.
So you should assume that the superclass is well initialized
> Of course all this came about after 1 1/2 days of tracking down what I
> thought was a bug but was the above situation so I might be totally
> wrong about the whole mess.
What I do in my system with newbie smalltalkers I put an empty class
initialize methods with a big error there so that I can see
what they do when I load their code.
I'm starting to talk liek an old man :)
Stef
>
> regards
> --
> Frank Caggiano "The best education for the best
> caggiano at crystal-objects.com is the best education for all."
> http://www.crystal-objects.com/ Robert M. Hutchins
>
> Logo Users Ring
> http://www.crystal-objects.com/logo/logoring.html
>
>
>
>
>
More information about the Squeak-dev
mailing list
|