Mantis - Squeak
Viewing Issue Advanced Details
368 Any minor always 10-13-04 15:40 02-16-06 01:57
won't fix  
0000368: PositionalStream>>back is not doing what it says
The comment of the method back says "Go back one element and return it. ...", so I would expect this to be true

stream := ReadStream on: 'abc'.
stream next = stream back


stream := ReadStream on: 'abc'.
stream position: 1. "Between a and b"
first := stream back. "nil"
stream position: 1.
second := (stream skip: -1) peek. "$a"
first = second

But the results for both are false.

Why is back not just (stream skip: -1) peek?
Would it be ok to rewrite the few places where back and peekBack are used with more generic constructs and remove this methods?
I used back in a fix for 0000201, so I think that report should be reopened.
has duplicate 0006583closed  PositionableStream>>back behavior is totally wrong 

10-13-04 15:52   
That is PositionableStream
01-01-06 11:10   
Say the stream's at position n. Then "stream next" moves the position to n+1 and returns that element (the n+1th element). Invoking "stream back" then moves the position back to n and returns that element (the nth element). Thus, in general, stream next = stream back should be false.

The only time I can think of when "stream next = stream back" would be true is when the stream is empty.
01-03-06 22:11   
The position in streams is between elements, like that of a textcursor. Position starts at 0. With a stream at position n a next returns element n+1 and the position advances to n+1. With a position at n+1 a back should return character n+1 and move back to position n. So "stream next = stream back" should be true. At least this is what I would expect.