<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 6, 2018 at 1:32 PM, Norbert Hartl <span dir="ltr"><<a href="mailto:norbert@hartl.name" target="_blank">norbert@hartl.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br><div style="word-wrap:break-word">Btw. why is the name NoModificationError? Isn’t the purpose of an Error that it is not resumable? And is NoModificationError very likely to be resumed? Like in #retryModification?</div></blockquote><div><br></div><div>Normally the NoModificationError should be able to retry the modification, and then resumes execution just after the primitive call / the inst var store. </div><div><br></div><div>In the case of primitive failure I guess either the error should resume with the value to return or the primitive fall-back code should return the correct value. In the case of inst var store, we need to resume execution using #jump (See #attemptToAssign: value withIndex: index)</div><div> </div><div>For at:put: we could have:</div><div><br></div><div><div style="font-size:12.8px"><span class="gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">   </span><primitive: 174 error: ec></div><div style="font-size:12.8px"><span class="gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">  </span>self isReadOnlyObject </div><div style="font-size:12.8px"><span class="gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">           </span>ifTrue: [<b>^ </b>(ModificationForbidden for: self atInstVar: index with: anObject) signal]</div><div style="font-size:12.8px"><span class="gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">           </span>ifFalse: [ self primitiveFailed ]</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">OR </div><div><br></div><div><div style="font-size:12.8px"><span class="gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">       </span><primitive: 174 error: ec></div><div style="font-size:12.8px"><span class="gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">  </span>self isReadOnlyObject </div><div style="font-size:12.8px"><span class="gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">           </span>ifTrue: [(ModificationForbidden for: self atInstVar: index with: anObject) signal. <b>^ anObject</b>]</div><div style="font-size:12.8px"><span class="gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">         </span>ifFalse: [ self primitiveFailed ]</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">+ the index bound check mentioned by Eliot and asInteger trick (based on at: primitive failure code)</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">So that when the exception resumes the correct behavior happens.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>Norbert<br><div><br><blockquote type="cite"><div>Am 05.01.2018 um 14:34 schrieb Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>>:</div><br class="gmail-m_-4419134607335559338Apple-interchange-newline"><div><div dir="auto"><div>Hi Clément,</div><div><br></div><div>    is it too late to take a look at the VisualWorks code and use the same class names and selectors they use?  IIRC it is NoMidificationError.  It may make e.g. Gemstone's job easier if there is some consistency.<br><br><span style="background-color:rgba(255,255,255,0)">_,,,^..^,,,_ (phone)</span></div><div><br>On Jan 5, 2018, at 5:22 AM, Clément Bera <<a href="mailto:bera.clement@gmail.com" target="_blank">bera.clement@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><span></span></div></blockquote><blockquote type="cite"><div><div dir="ltr"><div>Hi,</div><div><br></div><div>No this is not a bug.</div><div><br></div>This needs to be handled in the primitive failure code in the image, the method should be something like that :<div><br><div><div><font face="monospace, monospace">Object>>instVarAt: index put: anObject</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">      </span><primitive: 174 error: ec></font></div><div><font face="monospace, monospace">        self isReadOnlyObject ifTrue: [(ModificationForbidden for: self atInstVar: index with: anObject) signal]</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>self primitiveFailed</font></div><div><br></div><div>All primitive fall-back code triggering object mutation should be rewritten this way, especially primitives such as #at:put:, #instVarAt:put:, etc.</div><div><br></div></div></div><div>Cheers</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 5, 2018 at 1:42 PM, Norbert Hartl <span dir="ltr"><<a href="mailto:norbert@hartl.name" target="_blank">norbert@hartl.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br><div style="word-wrap:break-word">If I do <div><br></div><div><div>(#foo -> #bar)</div><div><span class="gmail-m_-4419134607335559338m_-2406158539713268726Apple-tab-span" style="white-space:pre-wrap">        </span>beReadOnlyObject;</div><div><span class="gmail-m_-4419134607335559338m_-2406158539713268726Apple-tab-span" style="white-space:pre-wrap">     </span>value: #baz</div></div><div><br></div><div>it throws</div><div><br></div><div><b>ModificationForbidden:  #foo->#bar is read-only, hence its field 2 cannot be modified with #baz</b></div><div><br></div><div> which is as expected. But if I do</div><div><br></div><div><div>(#foo -> #bar)</div><div><span class="gmail-m_-4419134607335559338m_-2406158539713268726Apple-tab-span" style="white-space:pre-wrap"> </span>beReadOnlyObject;</div><div><span class="gmail-m_-4419134607335559338m_-2406158539713268726Apple-tab-span" style="white-space:pre-wrap">     </span>instVarNamed: #value put: #baz</div></div><div><br></div><div>I get</div><div><br></div><div><b>PrimitiveFailed: primitive #instVarAt:put: in Association failed</b></div><div><br></div><div>I think this a bug, no?</div><div><br></div><div>Norbert</div></div><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-4419134607335559338gmail_signature"><div dir="ltr"><span style="font-size:12.8px">Clément Béra</span><div style="font-size:12.8px">Pharo consortium engineer</div><div style="font-size:12.8px"><a href="https://clementbera.wordpress.com/" target="_blank">https://clementbera.wordpress.<wbr>com/</a><br></div><div style="font-size:12.8px"><span style="line-height:16px">Bâtiment B 40, avenue Halley 59650 </span><span style="font-weight:bold;line-height:16px">Villeneuve d'Ascq</span></div></div></div>
</div>
</div></blockquote></div></div></blockquote></div><br></div></div><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><span style="font-size:12.8px">Clément Béra</span><div style="font-size:12.8px">Pharo consortium engineer</div><div style="font-size:12.8px"><a href="https://clementbera.wordpress.com/" target="_blank">https://clementbera.wordpress.com/</a><br></div><div style="font-size:12.8px"><span style="line-height:16px">Bâtiment B 40, avenue Halley 59650 </span><span style="font-weight:bold;line-height:16px">Villeneuve d'Ascq</span></div></div></div>
</div></div>