2012/6/16 Stéphane Ducasse <[email protected]>: > > On Jun 16, 2012, at 11:00 AM, Nicolas Cellier wrote: > >> 2012/6/16 Stéphane Ducasse <[email protected]>: >>>> >>>> >>>> On Jun 15, 2012, at 12:06 PM, Stéphane Ducasse <[email protected]> >>>> 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 > > what is the class side? :) >
I would explain it this way, as viewed from a st-80 browser: - you select instance radio button, and see the messages you can send to instances of the class. - you select class radio button, and see the messages you can send to the class itself. Of course, it's not exactly that simple because of inheritance: the browser doesn't show the messages implemented in superclasses that we can send too. There are hierarchy browsers... Except they don't really help with class side inheritance, that's what make it complex for noobs IMO. >> because >> instances are created from a kind of structural template (how many >> variables, etc...). You can also create an instance by cloning with >> copy… > > I have been there. Teaching a lot during many years and there is no simple > explanation: after two hours of lecture you do not want to explain > metaclasses. Just because people forgot (CLOS did not do this mistake) to > invoke an initialize method when creating an object. > > At the end I added in all my system the Behavior new>> self basicNew > initialize > and the students were happy and me too. > Sure, I also find this addition valuable beside teaching. Nicolas > >> But initialize is on instance size because it modifies the private >> instance variables: >> 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... >> >> Nicolas >> > >
