[squeak-dev] Would a PositionableStream>>#peek: be reasonable?

Chris Muller asqueaker at gmail.com
Sun Oct 7 02:07:30 UTC 2018


I have a ReadStream I would like to peek at the next few characters
instead of only the very next character.  Here's a simple 1-minute
implementation proposal, but since it seems strange this was never
added before, I wanted to check my sanity with the brilliant developer
folk, here.

PositionableStream>>peek: anInteger
    "Answer what would be returned if the message next: anInteger
without advancing the internal position pointer."
    | priorPos result |
    priorPos := position.
    result := self next: anInteger.
    position := priorPos.
    ^ result

Thanks,
  Chris


More information about the Squeak-dev mailing list