Dear Squeakers,
I just found out that we have quite a few unreferenced instance variables. I found 139 classes in a current trunk image. I used the following script: | unreferencedInstVars | unreferencedInstVars := Dictionary new. SystemNavigation default allBehaviorsDo: [:each | | instVars | (instVars := each unreferencedInstanceVariables) notEmpty ifTrue: [unreferencedInstVars at: each put: instVars]]. unreferencedInstVars Could all of these be removed? Or are there reasons why some of those inst vars must not be deleted? Curiously, Bernhard |
On Mon, 13 Dec 2010, Bernhard Pieber wrote:
> Dear Squeakers, > > I just found out that we have quite a few unreferenced instance variables. I found 139 classes in a current trunk image. I used the following script: > > | unreferencedInstVars | > unreferencedInstVars := Dictionary new. > SystemNavigation default allBehaviorsDo: [:each | > | instVars | > (instVars := each unreferencedInstanceVariables) notEmpty > ifTrue: [unreferencedInstVars at: each put: instVars]]. > unreferencedInstVars > > Could all of these be removed? Or are there reasons why some of those inst vars must not be deleted? Some of them (probably most) can be safely removed, but there are some exceptions like Process' island and env. Levente > > Curiously, > Bernhard > |
In reply to this post by bpi
An inst-var could, theoretically be used but still appear unreferenced
if access to it was only via instVarNamed: and instVarNamed:put:. Doubtful, but to be extra safe, we might want to check String literals equal to the inst-var name as part of the research of removing an instVar... On Mon, Dec 13, 2010 at 3:21 PM, Bernhard Pieber <[hidden email]> wrote: > Dear Squeakers, > > I just found out that we have quite a few unreferenced instance variables. I found 139 classes in a current trunk image. I used the following script: > > | unreferencedInstVars | > unreferencedInstVars := Dictionary new. > SystemNavigation default allBehaviorsDo: [:each | > | instVars | > (instVars := each unreferencedInstanceVariables) notEmpty > ifTrue: [unreferencedInstVars at: each put: instVars]]. > unreferencedInstVars > > Could all of these be removed? Or are there reasons why some of those inst vars must not be deleted? > > Curiously, > Bernhard > |
+1, I've had this same issue with "unsent" messages getting sent with #perform:orSendTo: et al. Metaprogramming (well, I suppose it's really just late binding) makes it hard to know for certain what's used and what isn't; it's worth searching sources for the string just to be sure.
I've become awfully interested in analyzing dependencies in ST for this very reason. It's hard/fun:) On Dec 14, 2010, at 11:28 AM, Chris Muller <[hidden email]> wrote: > An inst-var could, theoretically be used but still appear unreferenced > if access to it was only via instVarNamed: and instVarNamed:put:. > Doubtful, but to be extra safe, we might want to check String literals > equal to the inst-var name as part of the research of removing an > instVar... > > On Mon, Dec 13, 2010 at 3:21 PM, Bernhard Pieber <[hidden email]> wrote: >> Dear Squeakers, >> >> I just found out that we have quite a few unreferenced instance variables. I found 139 classes in a current trunk image. I used the following script: >> >> | unreferencedInstVars | >> unreferencedInstVars := Dictionary new. >> SystemNavigation default allBehaviorsDo: [:each | >> | instVars | >> (instVars := each unreferencedInstanceVariables) notEmpty >> ifTrue: [unreferencedInstVars at: each put: instVars]]. >> unreferencedInstVars >> >> Could all of these be removed? Or are there reasons why some of those inst vars must not be deleted? >> >> Curiously, >> Bernhard >> > |
Free forum by Nabble | Edit this page |