[squeak-dev] PositionableStream >> #peekBack behavior
asqueaker at gmail.com
Sat Aug 8 21:21:27 UTC 2020
> > I can see the nil being returned there explicitly, so that's "where it's
> happening." Should this be the case though?
> The previous, probably original implmenetation of #peekBack used to send
> #oldBack to the stream.
> IIRC #oldBack was based on the idea that the position of a stream is an
> index of a sequence where #next means +1 to that index while #back means
> -1 to that index. Following that logic, you have to #skip: -2 and send
> #next to get the element -1 to position.
> #oldBack has been removed but the behavior of #peekBack is presumably the
> same as it was before. Some ancient but now external code may rely on
> #peekBack but it's not very likely such code would work in the current
> #peekBack has no real users in the Trunk only a test remembers what it
> used to do.
Given the above, and given that we have #next:, I ended up balancing that
API with #peek:, and that again with #peekBack:. Since they all simply
return a String, possibly empty, they dodge the question about nil vs.
So, I think it's a good time to change its behavior to be based on #back.
Without wanting to sound ungrateful for Eric's contribution (of which I
look forward to more of), may we also consider the addition-by-subtraction
opportunity? I mean, it kinda makes sense that there wouldn't, and won't,
be any users of #peekBack. Maybe we should deprecate it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev