[squeak-dev] The Inbox: Collections-EG.908.mcz

Levente Uzonyi leves at caesar.elte.hu
Sat Aug 8 16:38:24 UTC 2020


Hi Eric,

On Fri, 7 Aug 2020, Eric Gade wrote:

> Hi Dave,
> 
> On Fri, Aug 7, 2020 at 10:14 PM David T. Lewis <lewis at mail.msen.com> wrote:
>       Actually, I think that the new ReadStreamTest>>testPeekBack is not in
>       agreement with the existing RWBinaryOrTextSteamTest>>testPeekBack.
> 
> 
> Looks like I got too excited and neglected to run the full test suite, apologies!
>  
>       If I understand correctly, peek means "show me the next element that
>       has not yet been read from the stream", and peekBack means "show me the
>       element before the one that was most recently read from the stream".
>       So I expect that peekBack would mean to skip back 2 from the current
>       position, not skip back 1.
> 
> 
> I see what you are saying and that makes sense to me. My thinking was that stream positions are always "between" the elements, and that a "peek forward" just means "grab the element but don't advance the position. In that
> case, peeking backward would do the same in the reverse direction: look one element back but not decrement the position.
> 
> Because there are no senders I guess this isn't a big deal and we can trash the changes. It came up because I'm thinking of porting my refactor of GIFReadWriter and animated image parsing that I did for Pharo about a year
> ago. I use peekBack in a couple of places there but can definitely figure out another way to achieve the same result. (I'll save the GIF discussion for a later email because it's ... complicated).

That sounds really cool. I hope it fixes the bug Karl reported early this 
year[1] (see the attached gif if you don't know). When I had a look at the 
code, I felt like rewriting it would be easier than fixing it.

Now that I know the context of where you intend to use #peekBack, I 
suggest you shouldn't use it but rather store what #next returned in a 
variable.
That should make a significant difference in performance if used in a 
tight loop.


Levente

[1] http://forum.world.st/BUG-GIFReadWriter-td5109760.html

> 
> Thanks!
>  
>
>       Dave
> 
> --
> Eric
> 
>


More information about the Squeak-dev mailing list