<div dir="ltr">Hi Norbert,<div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 6, 2018 at 6:09 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br><div style="word-wrap:break-word;line-break:after-white-space">Thanks Clement!<br><div><br><blockquote type="cite"><div>Am 06.01.2018 um 14:44 schrieb Clément Bera <<a href="mailto:bera.clement@gmail.com" target="_blank">bera.clement@gmail.com</a>>:</div><br class="m_7555836848595207003Apple-interchange-newline"><div><br class="m_7555836848595207003Apple-interchange-newline"><br style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On Sat, Jan 6, 2018 at 1:32 PM, Norbert Hartl<span class="m_7555836848595207003Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:norbert@hartl.name" target="_blank">norbert@hartl.name</a>></span><span class="m_7555836848595207003Apple-converted-space"> </span>wro<wbr>te:<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"> <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></div></blockquote>I was actually asking why the mentioned NoModificationError is an error and not a NoModificationException. </div></div></blockquote><div><br></div><div>Ah, that's a great distinction.  Indeed NoModificationException is a better name.  So ignore my comments about orthogonality.  I like the distinction between exceptions being resumable and errors not,.  I've learned something.  Thank you.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><br><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><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="m_7555836848595207003gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">      </span><primitive: 174 error: ec></div><div style="font-size:12.8px"><span class="m_7555836848595207003gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">     </span>self isReadOnlyObject </div><div style="font-size:12.8px"><span class="m_7555836848595207003gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">              </span>ifTrue: [<b>^<span class="m_7555836848595207003Apple-converted-space"> </span></b>(ModificationForbidden for: self atInstVar: index with: anObject) signal]</div><div style="font-size:12.8px"><span class="m_7555836848595207003gmail-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="m_7555836848595207003gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">  </span><primitive: 174 error: ec></div><div style="font-size:12.8px"><span class="m_7555836848595207003gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">     </span>self isReadOnlyObject </div><div style="font-size:12.8px"><span class="m_7555836848595207003gmail-m_1237586985416883183Apple-tab-span" style="white-space:pre-wrap">              </span>ifTrue: [(ModificationForbidden for: self atInstVar: index with: anObject) signal.<span class="m_7555836848595207003Apple-converted-space"> </span><b>^ anObject</b>]</div><div style="font-size:12.8px"><span class="m_7555836848595207003gmail-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></div></div></blockquote>I have now</div><div><br></div><div><div>at: index put: value </div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">   </span>"Primitive. Assumes receiver is indexable. Store the argument value in </div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">      </span>the indexable element of the receiver indicated by index. Fail if the </div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">    </span>index is not an Integer or is out of bounds. Or fail if the value is not of </div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">      </span>the right type for this kind of collection. Answer the value that was </div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">    </span>stored. Essential. See Object documentation whatIsAPrimitive."</div><div><br></div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">       </span><primitive: 61></div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">      </span>index isInteger </div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">          </span>ifTrue: [self class isVariable</div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">                     </span>ifTrue: [(index between: 1 and: self size)</div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">                         </span>ifFalse: [self errorSubscriptBounds: index]]</div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">                       </span>ifFalse: [self errorNotIndexable]]</div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">         </span>ifFalse: [  </div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">                      </span>index isNumber</div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">                             </span>ifTrue: [^self at: index asInteger put: value]</div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">                             </span>ifFalse: [self errorNonIntegerIndex] ].</div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">    </span>self isReadOnlyObject </div><div><span class="m_7555836848595207003Apple-tab-span" style="white-space:pre-wrap">            </span>ifTrue: [ ^ (InstVarModificationForbidden for: self atInstVar: index with: value) signal ].</div><div><br></div><div>Norbert</div><div><br></div><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><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 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="m_7555836848595207003gmail-m_-4419134607335559338Apple-interchange-newline"><div><div dir="auto"><div>Hi Clément,</div><div><br></div><div>   <span class="m_7555836848595207003Apple-converted-space"> </span>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">       <span class="m_7555836848595207003Apple-converted-space"> </span>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 class="m_7555836848595207003Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:norbert@hartl.name" target="_blank">norbert@hartl.name</a>></span><span class="m_7555836848595207003Apple-converted-space"> </span>wro<wbr>te:<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"> <br><div style="word-wrap:break-word">If I do <div><br></div><div><div>(#foo -> #bar)</div><div><span class="m_7555836848595207003gmail-m_-4419134607335559338m_-2406158539713268726Apple-tab-span" style="white-space:pre-wrap">        </span>beReadOnlyObject;</div><div><span class="m_7555836848595207003gmail-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="m_7555836848595207003gmail-m_-4419134607335559338m_-2406158539713268726Apple-tab-span" style="white-space:pre-wrap">    </span>beReadOnlyObject;</div><div><span class="m_7555836848595207003gmail-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>--<span class="m_7555836848595207003Apple-converted-space"> </span><br><div class="m_7555836848595207003gmail-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 style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br clear="all" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><span style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">--<span class="m_7555836848595207003Apple-converted-space"> </span></span><br style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="m_7555836848595207003gmail_signature" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><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></blockquote></div><br></div><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="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>