Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Class Extensions
Last updated at 11:18 pm UTC on 14 March 2005
Question: Say you have an extension in some class which requires an extra class variable. How would you get that class variable into a system, given that MC doesn't really track such changes?

Answer: On Mar 9, 2004, Andreas Raab You make a class side #initialize methods which looks like:
 Foo class>>initialize
     "Make sure that the class variable is present"
     (self classPool includesKey: #MyVariable) ifFalse:[
         self addClassVar: #MyVariable.
     ].
     MyVariable := 42.
Comment: Colin Putney
I use something similar in OmniBrowser. One of my tests needs to make sure that image browsers see an extension method on particular class, but package browsers don't (because they're browsing the package that the class belongs to, not the extension.) Since the extension has to be in a different package, (ie, not OmniBrowser), I create it in a class-side initialize method.

It won't be hard to have Monticello support your situation properly, once there are mechanisms in the kernel for annotating variables.

See also How to port old code to modules