[squeak-dev] Instance variable access in superclasses.

Igor Stasenko siguctua at gmail.com
Tue Nov 25 10:40:29 UTC 2008


2008/11/25 Michael van der Gulik <mikevdg at gmail.com>:
> Hi all.
>
> What would people's reaction be if a class was prevented from being able to
> directly access its superclass's instance variables? A subclass should use
> accessor methods to access a superclass's instance variables.
>
> Is there any particular reason subclasses get access to superclass instance
> variables? I think it breaks encapsulation.
>
> If this was implemented, it might be possible to avoid needing to recompile
> every subclass when you modify the instance variables of a class.
>
No, you can't avoid recompiling.
Suppose base class having vars:
0 - a
1 - b

and subclass

2 - d
3 - c

now, if you add or remove vars in base class, indexes of 'd' and 'c'
variables will be shifted correspondingly. And therefore it would
require to recompile all methods where you using 'd' and 'c' ivars. It
also may require recompiling methods in base class, when you inserting
a var before a or b.. or removing var 'a'. - for same reason - indexes
will be shifted.

> Gulik.
>
> --
> http://people.squeakfoundation.org/person/mikevdg
> http://gulik.pbwiki.com/
>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list