<div dir="ltr">Hi Bert,<div class="gmail_extra"><br></div><div class="gmail_extra">   [please see the "however" later on]</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 18, 2017 at 7:30 AM, 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 4:09 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></span><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"><span>On Tue, 18 Jul 2017, marcel.taeumel wrote:<br>
<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">
Hi, there.<br>
<br>
Why are there guards to prevent forward-becoming to immediates (chars, ints)<br>
but not to symbols?<br>
</blockquote>
<br></span>
The former is technically impossible due to different object representations, the latter is possible and not restricted at all. For example, true and false are not immediate objects, you can use #become*: on them to blow your image up.<br>
So, there's no restriction at all if it's technically possible to use #become*:.<br>
The responsibility model is the simplest here: use at your own risk.<br>
Since this comes up every once in a while, I suggest a comment be added to those methods stating the responsibility model explicitly.<br></blockquote><div><br></div></span><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​+1</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)">*Especially* a warning that becomeForward: does modify the target's hash.</div><span class="gmail-"><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​</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">
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.</blockquote><div><br></div></span><div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​I think that would be fine, you should​ be able to become an immutable object and vice versa.</div></div><span class="gmail-"><div> </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"> 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.</blockquote><div><br></div></span><div><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​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 immutable, no?</div></div></div></div></div></blockquote><div><br></div><div>Agreed.  I'm modifying the Spur VM to fail becomeForward: when copyHash is true and the target object is immutable.  So when we have immutable literals, #normal would be immutable and the become would fail.  The operative code was</div><div><br></div><div><div>containsOnlyValidBecomeObjects: array1 and: array2 twoWay: isTwoWay copyHash: copyHash</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">...</span></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>[fieldOffset >= self baseHeaderSize] whileTrue:<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">           </span>[...</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">           </span> isTwoWay</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                      </span>ifTrue:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                </span>[...]</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                  </span>ifFalse:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">>>                               </span>[(copyHash and: [self isImmediate: oop2]) ifTrue:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">>>                                      </span>[^PrimErrInappropriate]].</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span> fieldOffset := fieldOffset - self bytesPerOop].</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">...</span></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>^0<br></div></div><div><br></div><div>and is now</div><div><br></div><div><div>containsOnlyValidBecomeObjects: array1 and: array2 twoWay: isTwoWay copyHash: copyHash</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">...</span></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>[fieldOffset >= self baseHeaderSize] whileTrue:<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">           </span>[...</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">           </span> isTwoWay</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                     </span>ifTrue:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                </span>[...]</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                  </span>ifFalse:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">>>                               </span>[(copyHash and: [(self isImmediate: oop2) or: [self isImmutable: oop2]]) ifTrue:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">>>                                       </span>[^PrimErrInappropriate]].</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span> fieldOffset := fieldOffset - self bytesPerOop].</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">...</span></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>^0<br></div></div><div><br></div><div>This was a slip on mine and Clément's part when we added read-only object support.</div><div><br></div><div>However, it seems to me that becomerForward: doing a copyHash is itself a bug.  What's the rationale for copying the receiver's hash to the target object?  I've seen various frameworks use become to clean-up objects by doing aNoLongerWantedObject becomeFor4ward: nil, and with our current default implementation for becomeForward: that will cause havoc.</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"><div><span class="gmail-HOEnZb"><font color="#888888"><div style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​- Bert -​<br></div></font></span></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"><span class="gmail-m_3855998634114174383HOEnZb"><font color="#888888">Levente</font></span><div class="gmail-m_3855998634114174383HOEnZb"><div class="gmail-m_3855998634114174383h5"><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">
This will break your image: "Object new becomeForward: #normal"<br>
<br>
... because Cursor class MNU #normal ... :-) Either this is a bug or<br>
forward-becoming to symbols is not intended at all.<br>
<br>
Best,<br>
Marcel<br></blockquote></div></div></blockquote></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>