<div dir="ltr"><div>In VA Smalltalk</div>
<div> </div>
<div> (WriteStream on: String new) nextPutAll: 'abc'; skip: -1;<br> contents</div>
<div> </div>
<div>also answers 'ab'.</div>
<div><br clear="all">John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.<br><br><br></div>
<div class="gmail_quote">On Thu, Oct 16, 2008 at 10:04 PM, Richard O'Keefe <span dir="ltr"><<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div class="Ih2E3d"><br>On 16 Oct 2008, at 8:14 pm, Paolo Bonzini wrote:<br><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">In the standard, the definition of #contents for <WriteStream> comes<br>from <collectionStream> so that this:<br>
<br> (WriteStream on: String new) nextPutAll: 'abc'; skip: -1;<br> contents<br><br>should "return a collection that contains the receiver's past and future<br>sequence values, in order", i.e. 'abc'. To me it makes more sense that<br>
it returns 'ab'.<br></blockquote><br></div>In Squeak and VisualWorks the answer is indeed 'ab',<br>which I find rather counterintuitive. The $c is,<br>after all, still part of the contents, and skip: 1<br>
will reveal it.<br><br>In implementation terms, it's the difference between<br><br> ^collection copyFrom: 1 to: position<br><br>and<br><br> ^collection copyFrom: 1 to: readLimit<br><br>My library, written to the standard, does the latter;<br>
Squeak and VisualWorks do the former.<br><br>The meaning of #contents in the standard is<br>"a collection containing the complete contents of the stream".<br><br>If you do<br> (ReadStream on: 'abc') skip: 2; contents<br>
you get all the characters, not just the remaining ones.<br><br>Nasty one: the standard's definition is simple, sensible,<br>and easy to implement (except for file streams, of course,<br>(:-)). But implementations do something else.<br>
<br>What do other Smalltalks than Squeak and VW do?
<div>
<div></div>
<div class="Wj3C7c"><br><br><br><br>_______________________________________________<br>ANSI-Smalltalk mailing list<br><a href="mailto:ANSI-Smalltalk@lists.openskills.org" target="_blank">ANSI-Smalltalk@lists.openskills.org</a><br>
<a href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk" target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br></div></div></blockquote></div><br></div>