Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000368 [Squeak] Any minor always 10-13-04 15:40 02-16-06 01:57
Reporter laza View Status public  
Assigned To
Priority normal Resolution won't fix  
Status closed   Product Version
Summary 0000368: PositionalStream>>back is not doing what it says
Description 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

or

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?
Additional Information I used back in a fix for 0000201, so I think that report should be reopened.
Attached Files

- Relationships
has duplicate 0006583closed  PositionableStream>>back behavior is totally wrong 

- Notes
(0000339 - 26 - 26 - 26 - 26 - 26 - 26)
laza
10-13-04 15:52

That is PositionableStream
 
(0003417 - 392 - 434 - 434 - 434 - 434 - 434)
FrankShearar
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.
 
(0003422 - 354 - 364 - 364 - 364 - 364 - 364)
laza
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.
 

- Issue History
Date Modified Username Field Change
10-13-04 15:40 laza New Issue
10-13-04 15:52 laza Note Added: 0000339
12-10-05 12:45 pmm Issue Monitored: pmm
01-01-06 11:10 FrankShearar Note Added: 0003417
01-03-06 22:11 laza Note Added: 0003422
02-16-06 01:57 laza Status new => closed
02-16-06 01:57 laza Resolution open => won't fix
08-20-08 08:29 matthewf Relationship added has duplicate 0006583


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
52 total queries executed.
38 unique queries executed.
Powered by Mantis Bugtracker