[Newbies] Re: new vs. initialize

Zulq Alam me at zulq.net
Wed Dec 10 18:19:32 UTC 2008


Hi Greg,

My comments are below...

Greg A. Woods; Planix, Inc. wrote:

 > Now I read on the WWW that the added sending of #initialize from
 > Behaviour>>new was added in 3.9.

Where did you read this? I've been using Squeak for a few years and as 
far as I know the default implementation of #new has always sent 
#initialize.

The history of Behaviour>>new shows one version dated 23-8-2003. This is 
well before 3.9.

> Just for fun I did a search for senders of #basicNew and I found quite a 
> few which are from #new methods in classes which subclass directly from 
> Object and which are in classes that also define their own #initialize 
> method.  The curious bit is how some of these #new methods do send 
> #initialize, but not all.  I'm guessing some that don't are for abstract 
> classes, but is it true that all are?

There are a number of reasons one might call #basicNew, e.g. 
compatibility with other dialects, limiting use of #new by signalling an 
error, avoiding the normal initialisation from an alternative 
constructor, etc. In most cases "super new" would also work.

Those that call intitialize may do so because they still need that 
method to be called, perhaps after doing something else. Some call it 
for compatability...

> 
> Also, doesn't this still create an _enormous_ portability problem with 
> other Smalltalks?
> 

Have a look at what Seaside and other cross dialect projects do. I 
believe but am not sure they all have some sort of "self basicNew 
initialize" on all their top level classes.

- Zulq


More information about the Beginners mailing list