<div dir="ltr"><div>I suspect that rather than ignoring the standard when implementing #peekFor:, most/all Smalltalk implementations already had #peekFor: implemented. 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> </div>
<div>Could this not be considered a documentation oversight that is a candidate for the Errata STEP? Oh, what Errata STEP? Bad me -- I'm the one who was supposed to create that STEP.</div>
<div><br clear="all">John O'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"><<a href="mailto:damien.cassou@gmail.com">damien.cassou@gmail.com</a>></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 "stream peek = anObject" which is clearer that way.<br>
<div>
<div></div>
<div class="Wj3C7c"><br>On Wed, Oct 1, 2008 at 3:35 AM, Richard O'Keefe <<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>> wrote:<br>> In the Smalltalk standard, we read<br>><br>> <a href="http://5.9.2.8/" target="_blank">5.9.2.8</a> Message: peekFor: anObject<br>
> Synopsis<br>> Peeks at the next object in the stream<br>> and returns true if it matches the argument,<br>> and false if not.<br>> Definition: <gettableStream><br>> Returns the result of sending #= to the first object<br>
> in the receiver's future sequence values with anObject<br>> as the argument. Returns false if the receiver has<br>> no future sequence values.<br>> Parameters<br>> anObject <Object> uncaptured<br>
> Return Value<br>> <boolean> unspecified<br>> Errors<br>> none<br>><br>> There is no faintest suggestion here that the state of the<br>> stream changes in any way. In particular, there is no<br>
> suggestion that a successful match will result in the stream<br>> being advanced.<br>><br>> However, the Blue Book says on page 199<br>><br>> Determine the response to the message [#]peek.<br>> If it is the same as the argument, anObject,<br>
> THEN INCREMENT THE POSITION REFERENCE and<br>> answer true. Otherwise answer false and do<br>> not change the position reference.<br>><br>> The comment in VisualWorks says<br>><br>
> Answer false and do not move the position<br>> if self next ~= anObject or if the receiver<br>> is at the end. Answer true and<br>> INCREMENT POSITION if self next = anObject.<br>
><br>> The comment in Squeak says<br>><br>> Answer false and do not move over the next element<br>> if it is not equal to the argument, anObject, or<br>> if the receiver is at the end. Answer true and<br>
> INCREMENT THE POSITION for accessing elements,<br>> if the next element is equal to anObject.<br>><br>> When I wrote my stream classes, I took the standard text literally,<br>> and my #peekFor: never advanced the stream position. Whoops!<br>
> I propose the following replacement for the definition:<br>><br>> Definition: <gettableStream><br>> If the receiver has no future sequence values,<br>> returns false. Otherwise, determines the result of<br>
> sending #= to the first object in the receiver's<br>> future sequence values with anObject as the argument.<br>> If that is false, return false with no change to the<br>> receiver's state. If #= answers true, the first<br>
> object is removed from the receiver's future sequence<br>> values and appended to the end of the receiver's past<br>> sequence values, then true is returned.<br>><br>><br>><br>><br>
><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><br><br><br></div></div><font color="#888888">--<br>Damien Cassou<br>Peter von der Ahé: «I'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>