<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 1, 2017 at 10:37 AM, Tony Garnock-Jones <span dir="ltr"><<a href="mailto:tonyg@ccs.neu.edu" target="_blank">tonyg@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 5/1/17 1:26 PM, Levente Uzonyi wrote:<br>
> I presume that a general purpose in-image solution would be more<br>
> complex. String already has too many subclasses (6 in Squeak), while at<br>
> the same time other kind of new subclasses would be welcome too, e.g.<br>
> Strings with 2-byte characters.<br>
> Since these properties are orthogonal, there would be many new<br>
> subclasses to cover all cases.<br>
<br>
</span>A classic motivating case for Traits, right?<br></blockquote><div><br></div><div>Alas no.  The problem with String's subclasses is that they're binary objects.  They have no inst vars in which one can cache a hash.  They're juts a flat vector of bytes.  If one added a trait to them the system would fail because there's no way to add an inst var to a binary object in the current Smalltalk object representation.  hence Levente's very clever idea of hiding the hash in a hidden header word.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Tony<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>