#peekFor:, Squeak, and ANSI

Richard A. O'Keefe ok at cs.otago.ac.nz
Thu Dec 19 00:46:31 UTC 2002


ANSI/NCITS 319-1998, top of page 261:
  5.9.2.8 Message:  pekkFor: anObject
    Synopsis
      Peeks at the next object in the stream and returns true
      if it matches the argument, and false if not.
    Definition: <gettableStream>
      Returns the result of sending #= to the first object in
      the receiver's future sequence values with anObject as the
      argument.  Returns false if the receiver has no future
      sequence values.

I'd paraphrase this in Smalltalk code as

    peekFor: anObject
      ^self atEnd not and: [self peek = anObject]

However, Squeak's implementations of #peekFor: could be paraphrased thus:

    peekFor: anObject
      ^(self atEnd or: [self peek ~= anObject])
        ifTrue:  [false]
        ifFalse: [self next. true]

I checked the manual for VAST 5.5, and it says the same thing:
if peekFor: anObject returns true, it has stepped over that object.

1. Is this an error in the ANSI specification?
2. Is this a deliberate change to make #peekFor: only do peeking?
3. Is this something Squeak and VAST have changed?
4. Do other Smalltalks do the same as Squeak?
5. Do I just have to delete #peekFor: from the list of "portable" methods?




More information about the Squeak-dev mailing list