[Pharo-project] Auto create new and initialize methods for new class?
nicolas.cellier.aka.nice at gmail.com
Sat Jun 16 05:00:54 EDT 2012
2012/6/16 Stéphane Ducasse <stephane.ducasse at inria.fr>:
>> On Jun 15, 2012, at 12:06 PM, Stéphane Ducasse <stephane.ducasse at inria.fr> wrote:
>>> why do you need an automatic new method?
>>> Because by default
>>> new invoke initialize
>>> and it works well.
>> Stéphane, I have been using VW Smalltalk and it creates new classes ,by default, with a #new method on the class side and a #initialize method on the instance side.
> yes I always hated hated so much to force teacher to kill student on metaclass altar after two weeks of smalltalk
Another point of view: creating an instance is on class side because
instances are created from a kind of structural template (how many
variables, etc...). You can also create an instance by cloning with
But initialize is on instance size because it modifies the private
one object can't directly modify another, except by kindly asking by
sending a message.
The instance is an object, the class is another, so the class kindly
ask the instance to initialize itself.
There's no trick here and it can't be more clear.
The only trick is how a class side new inherits from instance side
Behavior new, but we don't need this to explain initialize...
More information about the Pharo-dev