<div dir="ltr"><br><br><div class="gmail_quote">On Tue, Jul 29, 2008 at 9:21 AM, stephane ducasse <span dir="ltr">&lt;<a href="mailto:stephane.ducasse@free.fr">stephane.ducasse@free.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello<br>
<br>
I&#39;m reading newspeak spec and I like the idea of immutable strings.<br>
Now what does it really bring to us?</blockquote><div><br></div><div>Safety. &nbsp;One can no longer overwrite literals or methods (or anything else whose state you want to protect) accidentally.</div><div><br></div><div>Expressive power. &nbsp;One can use immutability as a write barrier in orthogonal persistence or distribution schemes (and other things) . &nbsp;One marks an object as immutable to indicate that it is persistent or distributed and its changes should be exported. &nbsp;The immutability scheme allows one to associate managers for specific objects that handle&nbsp;NoModificationErrors on a per-object basis. &nbsp;So if an object is immutable and has an appropriate manager that manager can temporarily enable immutablity for the object, allow the modification, communicate the modification (e.g. to a database or remote image) and then re-enable immutability. &nbsp;The framework allows an object to have multiple managers. &nbsp;(This is all standard Squeak and very similar to the code I wrote for VW. &nbsp;The VM code is also available from Cadence).</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Then does it mean that we could get rid of symbols<br>
immutability does not imply unique identity.</blockquote><div><br></div><div>No. &nbsp;As you point out Symbols are unique and so immutable strings don&#39;t replace them. &nbsp;But it is nice to have immutable Symbols. &nbsp;e.g. try to do this in your Squeak image:</div>
<div>&nbsp;&nbsp; &nbsp;#class pvtAt: 1 put: 0 asCharacter</div><div>Scary :)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
<br>
Stef<br>
<br>
</blockquote></div><br></div>