Ways of new

Derek Brans brans at nerdonawire.com
Tue May 6 05:21:08 UTC 2003


I think 'super new initialize' runs the risk of initializing the object more
than once
(eg., if the super class also defines new as 'super new initialize', you are
calling initialize at least twice).

My understanding is that basicNew just allocates memory for a new object and
passes you a pointer, thus ensuring that initialize has not been called yet.

Derek Brans
Nerd on a Wire
Web design that's anything but square
http://www.nerdonawire.com
phone: 604.874.6463
mailto: brans at nerdonawire.com

----- Original Message -----
From: "Anthony Adachi" <adachipro at yahoo.com>
To: <squeak-dev at lists.squeakfoundation.org>
Sent: Monday, May 05, 2003 10:03 PM
Subject: Ways of new


> Hello
>
> Looking at various examples of Smalltalk code I've
> noticed a couple of different ways to override new
> which are commonly used.
>
> One sends self the basicNew message...
>
> Whale >>new
> ^self basicNew initialize
>
> The other sends super the new message...
>
> Dog >> new
> ^ super new initialize
>
> Why is one implementation chosen over the other by
> some authors?
>
> Thanks,
>
> Anthony
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com
>
>
>




More information about the Squeak-dev mailing list