[squeak-dev] Instance variable access in superclasses.

Michael van der Gulik mikevdg at gmail.com
Tue Nov 25 21:08:36 UTC 2008


On Tue, Nov 25, 2008 at 11:40 PM, Igor Stasenko <siguctua at gmail.com> wrote:

> 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.
>

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.

-- 
http://people.squeakfoundation.org/person/mikevdg
http://gulik.pbwiki.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20081126/fe10c32d/attachment.htm


More information about the Squeak-dev mailing list