A class is "just" another object whose own class is Class. I actually don't know when the class initialisiation method is called after creation. As usual, if all it does is things you know to be safe, go ahead and call it manually.
On 9/29/08, Mark Volkmann mark@ociweb.com wrote:
On Sep 29, 2008, at 6:00 AM, Marcin Tustin wrote:
The initialize method on the class side will be called only when *the class* is initialised. You are thinking of the instance-side initialize method which is called each time you create an instance.
Wow. I wasn't aware that there was both a class and instance initialize method. Thanks for explaining that!
What causes the class initialize method to be invoked ... and reinvoked after I change it?
On 9/29/08, Mark Volkmann mark@ociweb.com wrote:
On Sep 28, 2008, at 11:32 PM, K. K. Subramaniam wrote:
On Sunday 28 Sep 2008 7:26:43 pm Mark Volkmann wrote:
I think my main issue is scoping. I want to define a constant that is associated with a class to avoid name conflicts.
See classes Color, Cursor or Float for examples of scoped constants: Color red Cursor wait Float pi
For constants that should be exposed to a few (but not all) classes, use pool dictionaries.
Thanks! This brings up another question. Where is a good place to initialize a constant? I see in the case of "Float pi" that it is held in a class variable that is initialized in the initialize method. Isn't it the case that the initialize method is only called if a Float object is created? Also, isn't it called every time a Float object is created? It seems that would mean if I followed that pattern for one of my own constants then I wouldn't be sure it was set and I'd pay the cost of setting it many times.
Mark Volkmann
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Mark Volkmann
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
On Mon, 2008-09-29 at 13:16 +0100, Marcin Tustin wrote:
A class is "just" another object whose own class is Class. I actually don't know when the class initialisiation method is called after creation. As usual, if all it does is things you know to be safe, go ahead and call it manually.
It is not called _after_ creation. You said it is just another object. And therefor it is part of the new call. The difference here is that when you create a class there is no initialize method. You define that later. So it is e.g. executed when load from Monticello or anything that creates the class at a whole including the initialize method.
I hope that comes near to what happens really :)
Norbert
On 9/29/08, Mark Volkmann mark@ociweb.com wrote: On Sep 29, 2008, at 6:00 AM, Marcin Tustin wrote:
> The initialize method on the class side will be called only > when *the class* is initialised. You are thinking of the > instance-side initialize method which is called each time > you create an instance. Wow. I wasn't aware that there was both a class and instance initialize method. Thanks for explaining that! What causes the class initialize method to be invoked ... and reinvoked after I change it? > On 9/29/08, Mark Volkmann <mark@ociweb.com> wrote: > On Sep 28, 2008, at 11:32 PM, K. K. Subramaniam > wrote: > > On Sunday 28 Sep 2008 7:26:43 pm Mark > Volkmann wrote: > I think my main issue is scoping. I > want to define a constant that is > associated with a class to avoid > name conflicts. > See classes Color, Cursor or Float for > examples of scoped constants: > Color red > Cursor wait > Float pi > > For constants that should be exposed to a > few (but not all) classes, use pool > dictionaries. > > Thanks! This brings up another question. Where is a > good place to initialize a constant? I see in the > case of "Float pi" that it is held in a class > variable that is initialized in the initialize > method. Isn't it the case that the initialize method > is only called if a Float object is created? Also, > isn't it called every time a Float object is > created? It seems that would mean if I followed that > pattern for one of my own constants then I wouldn't > be sure it was set and I'd pay the cost of setting > it many times. > > --- > Mark Volkmann > > > > > > _______________________________________________ > Beginners mailing list > Beginners@lists.squeakfoundation.org > http://lists.squeakfoundation.org/mailman/listinfo/beginners > > > _______________________________________________ > Beginners mailing list > Beginners@lists.squeakfoundation.org > http://lists.squeakfoundation.org/mailman/listinfo/beginners --- Mark Volkmann _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
"Norbert" == Norbert Hartl norbert@hartl.name writes:
Norbert> It is not called _after_ creation. You said it is just another Norbert> object. And therefor it is part of the new call. The difference Norbert> here is that when you create a class there is no initialize Norbert> method. You define that later. So it is e.g. executed when load Norbert> from Monticello or anything that creates the class at a whole Norbert> including the initialize method.
Norbert> I hope that comes near to what happens really :)
This dates back to the old .st fileins... the very last line of these fileins is "SomeClass initialize", meaning that the initialize method is actually called very explicitly once the class is loaded.
Modern code management systems simulate this in various ways.
beginners@lists.squeakfoundation.org