Squeak 3.8/3.9 and Behavior class new

Stéphane Ducasse stephane.ducasse at univ-savoie.fr
Sun May 14 10:25:53 UTC 2006


Hi klaus

> Hi Stef,
>
> I want to get rid of "Behavior class #new" because it can not be  
> overridden on the instance side by #initialize.

Do you mean that instead of

Behavior class>>new
	
	| classInstance |
	classInstance := self basicNew.
	classInstance methodDictionary: classInstance emptyMethodDictionary.
	classInstance superclass: Object.
	classInstance setFormat: Object format.
	^ classInstance

You would like to have

Behavior>>new
	
  	^ self basicNew initialize.

Behavior>>initialize

	self methodDictionary: self emptyMethodDictionary.
	self superclass: Object.
	self setFormat: Object format.
	^ self

And not Behavior class>>new

I tried and it seems to work. Indeed I guess that it could make  
sense. I'm thinking about the result of doing that.
Right now when we send a message new to a class this is not the new  
of Behavior but of Behavior class.

I sent the email to the list because I sugar low now and moving boxes  
around so I would appreciate feedback on this one.

Stef


> In my subclass of ClassDescription I currently am forced to  
> override #new on the class side :-(
>
> Does anything speak against NOT having any #new, #new:, etc, never 
> +ever on the *class* side of Behavior(s)?
>
> Best regards,
> Klaus
>
> P.S. Thank you Daniel for your insightful response.
>
> ------- Forwarded message -------
> From: "Daniel Vainsencher" <danielv at techunix.technion.ac.il>
> To: "Klaus D. Witzel" <klaus.witzel at cobss.ch>
> Cc:
> Subject: Re: Squeak 3.8/3.9 and Behavior class new
> Date: Sun, 14 May 2006 10:11:59 +0200
>
> Hi Klaus!
>
> I'm sorry, but I can't help you.
>
> If you look at the versions, you'll see that Stef Ducasse saved the
> exact same code before me, so maybe he'll know. My guess is that my  
> name
> is only there because of code-moving operations needed during  
> traits. If
> you're not doing so, I would recommend you use the traits browser when
> working with the kernel code, otherwise you have no way of knowing
> whether the Behavior>>new is actually composed in from a Traits (quite
> likely, though I didn't check).
>
> If you don't know how to install the Traits browser, ask on the list,
> I'm sure there are others that don't, and someone that does.
>
> Daniel
>
> Klaus D. Witzel wrote:
>> Hi Daniel,
>>
>> found your initials in the Behavior class #new method.  
>> Unfortunately this behavior (Behavior class's behavior, I mean)  
>> cannot be overridded except by overriding #new (which many people,  
>> including me, are reluctant to do). I created a subclass of  
>> ClassDescription and was wondering *where* instances of my class  
>> where initialized and it took me a while to realize it was hacked  
>> into #new on the class side of Behavior.
>>
>> Does anything speak against moving your initializing code to the  
>> instance side of Behavior, into an #initialize method (following  
>> the general pattern of how #new is implemented)? I ask because I  
>> do not want to break the implementation of traits (which I assume  
>> was the reason for introducing the above beginning with 3.8).
>>
>> Kind regards,
>> Klaus D. Witzel
>> klaus.witzel at cobss.ch
>>
>
>
>




More information about the Squeak-dev mailing list