[Q]Overriding "new"

Göran Hultgren gohu at rocketmail.com
Tue Mar 19 19:38:54 UTC 2002


Hi!

--- Martin Drautzburg <martin.drautzburg at web.de> wrote:
> What is the problem with overriding the Class method "new". Squeak

No problem if you know what you are doing... :-) One pattern that you often see is this:

new
 ^super new initialize

This way you ensure that the instance gets initialized.

> always warns me, and if I insist terrible things happen (low memory -
> crash).

Well, it won't happen if you know what you are doing. :-)

> I was subclassing Array2D and I gave it a Class Method
>         new
>                 ^ super width:3 height:3
> 
> which was obviously a bad idea, but why ?

Well, it works fine for me. My guess is that you actually added a new Class Method in some other
classe instead of in your own subclass? Could that be what you did? In that case you are changing
a very basic behaviour of Squeak and things will come crashing down hard on your head... :-) :-)

regards, Göran

=====
Göran Hultgren, goran.hultgren at bluefish.se
GSM: +46 70 3933950, http://www.bluefish.se
"Department of Redundancy department." -- ThinkGeek

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/



More information about the Squeak-dev mailing list