Each class needs its *own* initialize method. You can observe this behaviour as follows...
1. Create a new package MyPlay holding the following... Object subclass: #SomeClass SomeClass class>>#initialize self inform: 'Initializing... ' , self name. #SomeClass object: #SubClass "Notice that there was no inform message" 2. Export package to local disk using Monticello. 3. Delete MyPlay package. 4. Via Monticello load MyPlay package. Observe that you only get an inform message for SomeClass, and not SubClass. I wanted to understand this behaviour more, so I modified... SomeClass class>>#initialize self haltOnce. self inform: 'Initializing... ' , self name. ...then enabled haltOnce and repeated steps 2, 3, 4 -- which broke out from MCMethodDefinition>>postloadOver: which shows #initialize is only called on classes where #initialize is defined. So it seems that creating a new class does not call #initialize at all, let alone an inherited one. It is a Monticello behaviour. cheers -ben On Wed, Apr 29, 2015 at 8:25 PM, Jan Blizničenko <blizn...@fit.cvut.cz> wrote: > Hello > > It seems I misunderstood some concept of classes in Pharo. My problem is > following: > Let's say I have class named SomeClass (subclass of Object) and class named > SubClass (subclass of SomeClass). > > If I create instance variable on SomeClass and SomeClass>>#initialize which > initializes the variable, it gets initialized also when SubClass instance > is > created. > > Now I'm trying to do something similar for class-side variables, but with > no > success. > If I create class-side variable on SomeClass and SomeClass > class>>#initialize which initializes the variable, it gets initialized only > in SomeClass class, but not in SubClass class. > > What I mean: > > Object subclass: #SomeClass > > SomeClass class > instanceVariableNames: 'Ok' > > SomeClass class>>#initialize > super initialize. > Ok := true > > SomeClass class>>#isOk > ^ Ok > > SomeClass subclass: #SubClass > > calling "SomeClass isOk" returns true. > calling "SubClass isOk" returns nil. > > > now If I create method > > SubClass class>>#initialize > super initialize. > > SubClass initializes as I would expect from my experience with instance > initialization, so "SubClass isOk" now returns true. > > > I will appreciate any help. > > Jan > > > > -- > View this message in context: > http://forum.world.st/class-initialization-and-class-side-variables-tp4822869.html > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com. > >