<div dir="ltr"><div class="gmail_default" 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 Wed, Jul 19, 2017 at 11:16 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><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"><div dir="ltr">Hi Bert,<div class="gmail_extra"><br><div class="gmail_quote"><span class="gmail-">On Wed, Jul 19, 2017 at 6:10 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:1px solid 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>#[195 164] collect: [:c | c hex]</div><div>=> #[16 16]</div></div></div></blockquote><div><br></div></span><div>+1</div><div><br></div><div>at: index put: value </div><div><span class="gmail-m_4371713074044423577gmail-Apple-tab-span" style="white-space:pre-wrap">     </span><primitive: 61> "try primitiveAtPut, convert value to integer if that fails and try again" </div><div><span class="gmail-m_4371713074044423577gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>^ self byteAt: index put: value asInteger</div><div><br></div><div>is wrong.</div><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid 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><br></div><div>I think this should have raised an error. Tim?</div></div></div></blockquote><div><br></div></span><div>Why don't we simply remove the method? Tim may be using this in his benchmarks but I'm sure there's a better way.</div><div></div></div></div></div></blockquote></div><br></div><div class="gmail_extra"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">​Spoke to Tim. The problem is actually primitive 105, which allows this:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><div class="gmail_default"><br></div><div class="gmail_default">(ByteArray new: 10) replaceFrom: 1 to: 5 with: 'Hello'</div><div class="gmail_default">=> #[72 101 108 108 111 0 0 0 0 0]</div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">If you comment out the primitive call in ByteArray>>replaceFrom:to:with:startingAt: and also remove Tim's at:put:, it will fail. So if a VM does not implement the (optional) primitive 105, the fallback code is wrong.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">Using #asInteger in ByteArray>>at:put: is a simple fix for that. Or we have to fix the fallback code in ByteArray>>replaceFrom:to:with:startingAt:.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">I just committed the latter to the inbox but I'm not sure I like the implementation:</div><div class="gmail_default"><font color="#000000" face="arial, helvetica, sans-serif"><a href="http://source.squeak.org/inbox/Collections-bf.761.diff">http://source.squeak.org/inbox/Collections-bf.761.diff</a></font><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">Also, ByteArray may not be the only class suffering from this problem:</div><div class="gmail_default"><font color="#000000" face="arial, helvetica, sans-serif">SystemNavigation default browseAllSelect: [:cm | cm primitive = 105]</font><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">- Bert -​</div><br></div></div>