[squeak-dev] PositionableStream >> #peekBack behavior

David T. Lewis lewis at mail.msen.com
Sat Aug 8 22:10:11 UTC 2020


On Sat, Aug 08, 2020 at 04:21:27PM -0500, Chris Muller wrote:
> >
> > > 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
> > Trunk.
> > #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.
> error entirely.
> 
> 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.
> 

That's probably the best idea of all.

As far as I can tell, #peekBack was used in PositionableStream>>#backChunk
in the Squeak 3.8 era, but Levente's 3/22/2010 version of the method in
trunk today eliminated the need for it.

So given that nobody uses it and we don't know how it should work, +1 for deprecation.

And +1 to looking forward to more contributions from Eric :-)

Dave



More information about the Squeak-dev mailing list