Semantics of Set>>new in Squeak 3.9 -- To initialize or not to initialize?

stéphane ducasse ducasse at iam.unibe.ch
Tue Apr 4 20:50:15 UTC 2006


nicolas

is the init: -> initialize calls works in your image. Just alwasy  
cautious with those stuff.
Andreas was really surprise that squeak woudl continue to work and  
not dead slow when I introduce in my image
super new initialize :) but we cannot be that lucky all the time

On 4 avr. 06, at 22:03, nicolas cellier wrote:

> Le Mardi 04 Avril 2006 20:47, John Pierce a écrit :
>> Hi all,
>>
>> I am looking at the "new" class method in Squeak 3.9 (and maybe prior
>> to that). It appears that most classes implement "new" as:
>>
>>   ^ self basicNew initialize
>>
>> which is implemented in Behavior. But the "Set" class re-implements
>> "new" and does not invoke initialize.
>>
>> Is this behavior intended? I had a few classes that derive from
>> Dictionary and used to work without calling initialize. Now I must
>> explicitly invoke the constructor.
>>
>> Is this lack of congruency the desired behavior?
>>
>> John
>>
>
> Well, a lot of indexable-like classes do implement #initialize: ,  
> and a few
> implement #init: (Set and some subclasses of it, and also  
> SharedQueue).
>
> Sure, it would be more uniform and highly desirable to rename  
> #init: into
> #initialize: , but that said, we can say that the initialization  
> function
> does exist in Set (and thus Dictionary).
>
> So there are two possible implementations of new:
> The one in Behavior for classes really declared as variableSubclass
>  (self basicNew: n) initialize
> The one in other classes, faking an indexable behaviour, but  
> implementing this
> behaviour indirectly by the mean of an indexable instance variable
>  (self basicNew) initialize: n
>
> Note that since #initialize: has no default implementation in  
> ProtoObject, it
> rarely super initialize:, but if you subclass, you'd rather call  
> super.
>
> Depending on where you are subclassing, you might have to define  
> either
> initialize or initialize: in your subclass, and i think that it is  
> tolerable.
>
> We just should rename this init: method...
>
> Nicolas
>
>
>
>
>




More information about the Squeak-dev mailing list