Help!

Tim Olson tim at jumpnet.com
Tue Feb 24 20:10:16 UTC 1998


>The following example code which comes from Inside Smalltalk vol. II, does not
>work properly because the MotherDuck initialization method is not run anew
>each time its code is modified.

The MotherDuck class>>initialize method is a class initialization method, 
meant to be run once to set up the class variables etc. needed by the 
rest of the code.  The things that method sets up are not intended to be 
modified (or the modifications are very infrequent).  There is no real 
automatic way to detect when changes would require that the class 
initialization code be run again; it's mainly a manual operation.

If you find that you are changing the class variables frequently, then 
you should consider changing them to instance variables that are set up 
whenever a new instance of that class is created.


>(I must confess that I have no idea how the initialization methods gets 
>launched).

That is set up automatically when you fileOut: your ChangeSet. If any of 
the MetaClasses defined in the ChangeSet contains a method named 
"initialize" then code to invoke it is added at the end of the fileOut so 
that when it is filed in, the initialization takes place.  See 
ChangeSet>>FileOutPSFor:on: for details.





     -- tim





More information about the Squeak-dev mailing list