<br><br><div class="gmail_quote">On Tue, Nov 25, 2008 at 11:40 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2008/11/25 Michael van der Gulik &lt;<a href="mailto:mikevdg@gmail.com">mikevdg@gmail.com</a>&gt;:<br>
<div class="Ih2E3d">&gt; Hi all.<br>
&gt;<br>
&gt; What would people&#39;s reaction be if a class was prevented from being able to<br>
&gt; directly access its superclass&#39;s instance variables? A subclass should use<br>
&gt; accessor methods to access a superclass&#39;s instance variables.<br>
&gt;<br>
&gt; Is there any particular reason subclasses get access to superclass instance<br>
&gt; variables? I think it breaks encapsulation.<br>
&gt;<br>
&gt; If this was implemented, it might be possible to avoid needing to recompile<br>
&gt; every subclass when you modify the instance variables of a class.<br>
&gt;<br>
</div>No, you can&#39;t avoid recompiling.<br>
Suppose base class having vars:<br>
0 - a<br>
1 - b<br>
<br>
and subclass<br>
<br>
2 - d<br>
3 - c<br>
<br>
now, if you add or remove vars in base class, indexes of &#39;d&#39; and &#39;c&#39;<br>
variables will be shifted correspondingly. And therefore it would<br>
require to recompile all methods where you using &#39;d&#39; and &#39;c&#39; ivars. It<br>
also may require recompiling methods in base class, when you inserting<br>
a var before a or b.. or removing var &#39;a&#39;. - for same reason - indexes<br>
will be shifted.<br>
</blockquote></div><br>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.<br><br>It isn&#39;t necessarily a good idea. I haven&#39;t thought through the details yet.<br>
<br>Gulik.<br clear="all"><br>-- <br><a href="http://people.squeakfoundation.org/person/mikevdg">http://people.squeakfoundation.org/person/mikevdg</a><br><a href="http://gulik.pbwiki.com/">http://gulik.pbwiki.com/</a><br>