<div dir="ltr"><div><div>OK, I see this works anyway because ByteString>>at:put: will handle the case and use becomeForward:<br><br></div>But should we rely on this expectation? It comes from a Smalltalk where become: were cheap.<br>
</div>For example, WriteStream>>pastEndPut: does not preserve collection identity<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-25 14:28 GMT+01:00 <span dir="ltr"><<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Tobias Pape uploaded a new version of Collections to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Collections-topa.565.mcz" target="_blank">http://source.squeak.org/trunk/Collections-topa.565.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-topa.565<br>
Author: topa<br>
Time: 25 March 2014, 2:28:36.459 pm<br>
UUID: b7c264b3-1e69-494d-8979-6f71bc9b846d<br>
Ancestors: Collections-ul.564<br>
<br>
When a stream is created on a collection, it tries to keep<br>
using that collection instead of copying, even in the case<br>
of mutation of the original collection.<br>
<br>
The code removed prevented this.<br>
<br>
=============== Diff against Collections-ul.564 ===============<br>
<br>
Item was changed:<br>
----- Method: WriteStream>>nextPut: (in category 'accessing') -----<br>
nextPut: anObject<br>
"Primitive. Insert the argument at the next position in the Stream<br>
represented by the receiver. Fail if the collection of this stream is not an<br>
Array or a String. Fail if the stream is positioned at its end, or if the<br>
position is out of bounds in the collection. Fail if the argument is not<br>
of the right type for the collection. Optional. See Object documentation<br>
whatIsAPrimitive."<br>
<br>
<primitive: 66><br>
- ((collection class == ByteString) and: [<br>
- anObject isCharacter and:[anObject isOctetCharacter not]]) ifTrue: [<br>
- collection := (WideString from: collection).<br>
- ^self nextPut: anObject.<br>
- ].<br>
position >= writeLimit<br>
ifTrue: [^ self pastEndPut: anObject]<br>
ifFalse:<br>
[position := position + 1.<br>
^collection at: position put: anObject]!<br>
<br>
<br>
</blockquote></div><br></div>