On Tue, Nov 25, 2008 at 11:40 PM, Igor Stasenko siguctua@gmail.com wrote:
2008/11/25 Michael van der Gulik mikevdg@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.
I was thinking, briefly, about modifying the VM and object memory format so that instance variables are always indexed beginning from 0 for every subclass. Somehow.
It isn't necessarily a good idea. I haven't thought through the details yet.
Gulik.