<div dir="ltr">Hi all,<div><br></div><div>I am not sure that's what you are talking about, as there is no true immutability in the Cog VM but only read-only objects (terminology agreed upon on the VM mailing list after multiple long discussions and I will ignore further discussions on this matter), but in the case of the supported read-only objects, the VM checks if the object is read-only when performing become and *fails* the primitive if so. This is done when checking if the oop is a valid become object (hence, I believe in the case of becomeForward, only one object is checked). Among multiple reasons (implementation details, complexity, tricky cases, etc.), it was implemented this way as it is simpler and it is possible to write a work-around that way:</div><div><br></div><div><font face="monospace, monospace">readOnlyObject beWritableObject.</font></div><div><font face="monospace, monospace">readOnlyObject become: anotherWritableObject.</font></div><div><font face="monospace, monospace">readOnlyObject beReadOnlyObject.</font><br></div><div><br></div><div>However, if at some point someone implements true immutability (i.e. the object cannot be modified once created immutable and cannot be writable again) in the VM, then the work-around does not work and one could consider alternatives.</div><div><br></div><div>Best,</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 18, 2017 at 5:36 PM, Nicolas Cellier <span dir="ltr"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">2017-07-18 16:51 GMT+02:00 Bert Freudenberg <span dir="ltr"><<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><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 4:46 PM, Levente Uzonyi </span><span dir="ltr" style="font-family:arial,sans-serif;color:rgb(34,34,34)"><<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>></span><span style="font-family:arial,sans-serif;color:rgb(34,34,34)"> wrote:</span><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_3282118625710398272m_-7765163349044760564gmail-">On Tue, 18 Jul 2017, Bert Freudenberg wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">    ​I don't know how the VM handles immutability in this case, but it's possible that it wouldn't let #become*: affect immutable objects.<br>
<br>
<br>
​I think that would be fine, you should​ be able to become an immutable object and vice versa.<br>
 <br>
      On the other hand, I'm sure it would let you change fields of immutable objects via #become*:, but that's not an issue in your case.<br>
<br>
<br>
​This is debatable ...​ I would rather have the VM raise an error when trying to become a field of an immutable object. Immutable should mean<br>
immutable, no?<br>
</blockquote>
<br></span>
#become: would become slow again if we had to find all objects referencing the one we're about to swap. Or, we'd have to make the whole object graph immutable when we make an object immutable. In that case #become: could just fail when the receiver or the argument is immutable.<span class="m_3282118625710398272m_-7765163349044760564gmail-HOEnZb"><font color="#888888"><br></font></span></blockquote><div> </div></div><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. And "mutableObj becomeForward: immutableObj copyHash: false" should be the only allowed become case.</div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div></div></div></blockquote><div><br></div></span><div>What if I change a class or superclass of an immutable?<br></div><div>(think add or remove an instance variable)<br> <br></div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"></div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">- Bert -</div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">- Bert -​</div><br></div></div>
<br><br>
<br></blockquote></span></div><br></div></div>
<br><br>
<br></blockquote></div><br></div>