Hi, I need to retrieve the last object put on a Stream (well SmartRefStream does). This is very much like #ensureEndsWith:
There is back, but back leave the stream positionned before the last object.
((ReadWriteStream on: String new) nextPutAll: 'abc'; back) -> $c ((ReadWriteStream on: String new) nextPutAll: 'abc'; back; position) -> 2.
There is peekBack, but peekBack answers the last but one...
((ReadWriteStream on: String new) nextPutAll: 'abc'; peekBack) -> $b. ((ReadWriteStream on: String new) nextPutAll: 'abc'; peekBack; position) -> 3.
Note that neither back nor peekBack is understood by a WriteStream. It requires a ReadWriteStream.
Since peekBack is the sole sender of oldBack in trunk, I wonder who is using it? I ask because I'd like to change the meaning of peekBack to that of back instead of oldBack. Unless you have a better selector to propose?
2014-07-28 17:02 GMT+02:00 Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com>:
Hi, I need to retrieve the last object put on a Stream (well SmartRefStream does). This is very much like #ensureEndsWith:
There is back, but back leave the stream positionned before the last object.
((ReadWriteStream on: String new) nextPutAll: 'abc'; back) -> $c ((ReadWriteStream on: String new) nextPutAll: 'abc'; back; position) -> 2.
There is peekBack, but peekBack answers the last but one...
((ReadWriteStream on: String new) nextPutAll: 'abc'; peekBack) -> $b. ((ReadWriteStream on: String new) nextPutAll: 'abc'; peekBack; position) -> 3.
Note that neither back nor peekBack is understood by a WriteStream. It requires a ReadWriteStream.
Since peekBack is the sole sender of oldBack in trunk, I wonder who is using it? I ask because I'd like to change the meaning of peekBack to that of back instead of oldBack. Unless you have a better selector to propose?
More exactly, I'd like to implement PositionnableStream>>peekBackFor: anObject to return a Boolean like peekFor: and it would be a good thing that peekBack answers the same Object.
Hi Nicolas,
Why can't you use peekLast? Seems to me ensureEndsWith: should be implemented in terms of peekLast.
Aloha, Eliot (phone)
On Jul 28, 2014, at 5:05 AM, Nicolas Cellier nicolas.cellier.aka.nice@gmail.com wrote:
2014-07-28 17:02 GMT+02:00 Nicolas Cellier nicolas.cellier.aka.nice@gmail.com:
Hi, I need to retrieve the last object put on a Stream (well SmartRefStream does). This is very much like #ensureEndsWith:
There is back, but back leave the stream positionned before the last object.
((ReadWriteStream on: String new) nextPutAll: 'abc'; back) -> $c ((ReadWriteStream on: String new) nextPutAll: 'abc'; back; position) -> 2.
There is peekBack, but peekBack answers the last but one...
((ReadWriteStream on: String new) nextPutAll: 'abc'; peekBack) -> $b. ((ReadWriteStream on: String new) nextPutAll: 'abc'; peekBack; position) -> 3.
Note that neither back nor peekBack is understood by a WriteStream. It requires a ReadWriteStream.
Since peekBack is the sole sender of oldBack in trunk, I wonder who is using it? I ask because I'd like to change the meaning of peekBack to that of back instead of oldBack. Unless you have a better selector to propose?
More exactly, I'd like to implement PositionnableStream>>peekBackFor: anObject to return a Boolean like peekFor: and it would be a good thing that peekBack answers the same Object.
2014-07-28 21:46 GMT+02:00 Eliot Miranda eliot.miranda@gmail.com:
Hi Nicolas,
Why can't you use peekLast? Seems to me ensureEndsWith: should be
implemented in terms of peekLast.
Aloha, Eliot (phone)
On Jul 28, 2014, at 5:05 AM, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
Yes, peekLast sounds perfect. Case of blindness? Oh, I was looking in PositionnableStream which has peekBack... That might explain.
2014-07-28 17:02 GMT+02:00 Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com>:
Hi, I need to retrieve the last object put on a Stream (well SmartRefStream does). This is very much like #ensureEndsWith:
There is back, but back leave the stream positionned before the last object.
((ReadWriteStream on: String new) nextPutAll: 'abc'; back) -> $c ((ReadWriteStream on: String new) nextPutAll: 'abc'; back; position) -> 2.
There is peekBack, but peekBack answers the last but one...
((ReadWriteStream on: String new) nextPutAll: 'abc'; peekBack) -> $b. ((ReadWriteStream on: String new) nextPutAll: 'abc'; peekBack; position) -> 3.
Note that neither back nor peekBack is understood by a WriteStream. It requires a ReadWriteStream.
Since peekBack is the sole sender of oldBack in trunk, I wonder who is using it? I ask because I'd like to change the meaning of peekBack to that of back instead of oldBack. Unless you have a better selector to propose?
More exactly, I'd like to implement PositionnableStream>>peekBackFor: anObject to return a Boolean like peekFor: and it would be a good thing that peekBack answers the same Object.
squeak-dev@lists.squeakfoundation.org