<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 18, 2017 at 2:22 PM, Bert Freudenberg <span dir="ltr"><<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span class="gmail-"><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><span style="font-family:arial,sans-serif;color:rgb(34,34,34)">On Tue, Jul 18, 2017 at 10:10 PM, Eliot Miranda </span><span dir="ltr" style="font-family:arial,sans-serif;color:rgb(34,34,34)"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span><span style="font-family:arial,sans-serif;color:rgb(34,34,34)"> wrote:</span><br></div></span><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Bert,<div class="gmail_extra"><br><div class="gmail_quote"><span class="gmail-m_3645855914368468259gmail-"><span class="gmail-">On Tue, Jul 18, 2017 at 7:51 AM, Bert Freudenberg <span dir="ltr"><<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>></span> wrote:<br></span><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"></div><div class="gmail_extra"><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​+1 for making the whole object graph be immutable.</div></div></div></blockquote><div><br></div></span></span><span class="gmail-"><div>This really doesn't make sense as it prevents any kind of change at all, e.g. to the class hierarchy, and as Nicolas points out, prevents updating objects if their class definitions are modified.</div><div><br></div><div>When we added "immutability" to VisualWorks (actually read-only objects) we held off, and made only literals immutable.  I'd like to see us make CompiledMethods immutable too, but this wold introduce complications in condensing changes/sources, adding/deleting breakpoints, etc.  One can provide an exception handler or a beMutableWhile: facility to make it easy to temporarily make read-only objects writable.</div></span></div></div></div></blockquote><div><br></div><div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">Right.​</div></div><span class="gmail-"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Or are you meaning that when an object is made immutable all its sub-state is made immutable too?  (An idea I have no problems with,<br></div></div></div></div></blockquote><div><br></div></span><div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​Yes, that. Which means that immediates and nil/true/false should become immutable too. In fact, isn't any stateless object already immutable?</div></div></div></div></div></blockquote><div><br></div><div>Almost.  One can still do</div><div><br></div><div>    someClass adoptInstance: aStatelessObject</div><div>    aStatelessObject becomeForward: anOtherObject</div>    aStatelessObject pin<br>    aStatelessObject unpin</div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">provided it does't imply that classes can't change).</div></div></div></blockquote><div><br></div></span><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​The class should not be made immutable​, agreed, but you shouldn't be able change the shape of instances, me thinks.</div></div></div></div></blockquote><div><br></div><div>There are circumstances where that isn't the right thing to do, because read-only-ness can be overloaded:</div><div><br></div><div>- Object-to-database mappers may set read-only-ness on objects to intercept modifications (e.g. to add objects to a "to be written back" set).  It would be the manager's responsibility to handle the necessary temporary relaxation of read-only-ness when an object read-only for the purposes of the mapper has its shape changed.</div><div><br></div><div>- Debuggers may set read-only-ness to catch assignments.</div><div><br></div><div>Hence the exception raised for read-only violations needs to be rich enough to allow these kinds of things.  The idea is to have a read-only-ness manager that registers managers for objects, and defers to the relevant manager(s) to handle read-only-ness on error.<br></div><div><br></div><div>But since there will always be the primitives to set and unset read-only-ness, read-only-ness may not be in effect for the entirety of an object's lifetime, only most of the time.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-HOEnZb"><font color="#888888"><div><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif">​- Bert -​</span></div></font></span></div></div></div></blockquote><div> </div></div><div class="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>