<div dir="ltr"><div>I suspect that rather than ignoring the standard when implementing #peekFor:, most/all Smalltalk implementations already had #peekFor: implemented.&nbsp; Just to add to the list, the VA Smalltalk #peekFor: implementation (from 6/6/96 or earlier) also advances the stream when answering true.</div>

<div>&nbsp;</div>
<div>Could this not be considered a documentation oversight that is a candidate for the Errata STEP?&nbsp; Oh, what Errata STEP?&nbsp; Bad me -- I&#39;m the one who was supposed to create that STEP.</div>
<div><br clear="all">John O&#39;Keefe [|], Principal Smalltalk Architect, Instantiations Inc.<br><br><br></div>
<div class="gmail_quote">On Wed, Oct 1, 2008 at 2:42 AM, Damien Cassou <span dir="ltr">&lt;<a href="mailto:damien.cassou@gmail.com">damien.cassou@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I noticed that too when doing Nile. It seems all implementations<br>decided to implement #peekFor: the same way, ignoring the standard. I<br>
think the standard behavior is useless here because it is equivalent<br>to &quot;stream peek = anObject&quot; which is clearer that way.<br>
<div>
<div></div>
<div class="Wj3C7c"><br>On Wed, Oct 1, 2008 at 3:35 AM, Richard O&#39;Keefe &lt;<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>&gt; wrote:<br>&gt; In the Smalltalk standard, we read<br>&gt;<br>&gt; <a href="http://5.9.2.8/" target="_blank">5.9.2.8</a> Message: peekFor: anObject<br>
&gt; &nbsp;Synopsis<br>&gt; &nbsp; &nbsp;Peeks at the next object in the stream<br>&gt; &nbsp; &nbsp;and returns true if it matches the argument,<br>&gt; &nbsp; &nbsp;and false if not.<br>&gt; &nbsp;Definition: &lt;gettableStream&gt;<br>&gt; &nbsp; &nbsp;Returns the result of sending #= to the first object<br>
&gt; &nbsp; &nbsp;in the receiver&#39;s future sequence values with anObject<br>&gt; &nbsp; &nbsp;as the argument. &nbsp;Returns false if the receiver has<br>&gt; &nbsp; &nbsp;no future sequence values.<br>&gt; &nbsp;Parameters<br>&gt; &nbsp; &nbsp;anObject &lt;Object&gt; uncaptured<br>
&gt; &nbsp;Return Value<br>&gt; &nbsp; &nbsp;&lt;boolean&gt; unspecified<br>&gt; &nbsp;Errors<br>&gt; &nbsp; &nbsp;none<br>&gt;<br>&gt; There is no faintest suggestion here that the state of the<br>&gt; stream changes in any way. &nbsp;In particular, there is no<br>
&gt; suggestion that a successful match will result in the stream<br>&gt; being advanced.<br>&gt;<br>&gt; However, the Blue Book says on page 199<br>&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;Determine the response to the message [#]peek.<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;If it is the same as the argument, anObject,<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp;THEN INCREMENT THE POSITION REFERENCE and<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;answer true. &nbsp;Otherwise answer false and do<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;not change the position reference.<br>&gt;<br>&gt; The comment in VisualWorks says<br>&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp;Answer false and do not move the position<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;if self next ~= anObject or if the receiver<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;is at the end. &nbsp;Answer true and<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;INCREMENT POSITION if self next = anObject.<br>
&gt;<br>&gt; The comment in Squeak says<br>&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;Answer false and do not move over the next element<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;if it is not equal to the argument, anObject, or<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;if the receiver is at the end. &nbsp;Answer true and<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp;INCREMENT THE POSITION for accessing elements,<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;if the next element is equal to anObject.<br>&gt;<br>&gt; When I wrote my stream classes, I took the standard text literally,<br>&gt; and my #peekFor: never advanced the stream position. &nbsp;Whoops!<br>
&gt; I propose the following replacement for the definition:<br>&gt;<br>&gt; &nbsp;Definition: &lt;gettableStream&gt;<br>&gt; &nbsp; &nbsp;If the receiver has no future sequence values,<br>&gt; &nbsp; &nbsp;returns false. &nbsp;Otherwise, determines the result of<br>
&gt; &nbsp; &nbsp;sending #= to the first object in the receiver&#39;s<br>&gt; &nbsp; &nbsp;future sequence values with anObject as the argument.<br>&gt; &nbsp; &nbsp;If that is false, return false with no change to the<br>&gt; &nbsp; &nbsp;receiver&#39;s state. &nbsp;If #= answers true, the first<br>
&gt; &nbsp; &nbsp;object is removed from the receiver&#39;s future sequence<br>&gt; &nbsp; &nbsp;values and appended to the end of the receiver&#39;s past<br>&gt; &nbsp; &nbsp;sequence values, then true is returned.<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>
&gt;<br>&gt; _______________________________________________<br>&gt; ANSI-Smalltalk mailing list<br>&gt; <a href="mailto:ANSI-Smalltalk@lists.openskills.org">ANSI-Smalltalk@lists.openskills.org</a><br>&gt; <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>
&gt;<br><br><br><br></div></div><font color="#888888">--<br>Damien Cassou<br>Peter von der Ahé: «I&#39;m beginning to see why Gilad wished us good<br>luck». (<a href="http://blogs.sun.com/ahe/entry/override_snafu" target="_blank">http://blogs.sun.com/ahe/entry/override_snafu</a>)<br>
</font><br>_______________________________________________<br>ANSI-Smalltalk mailing list<br><a href="mailto:ANSI-Smalltalk@lists.openskills.org">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>
<br></blockquote></div><br></div>