Can we change the meaning of peekBack?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Can we change the meaning of peekBack?

Nicolas Cellier
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?



Reply | Threaded
Open this post in threaded view
|

Re: Can we change the meaning of peekBack?

Nicolas Cellier



2014-07-28 17:02 GMT+02:00 Nicolas Cellier <[hidden email]>:
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.


Reply | Threaded
Open this post in threaded view
|

Re: Can we change the meaning of peekBack?

Eliot Miranda-2
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 <[hidden email]> wrote:




2014-07-28 17:02 GMT+02:00 Nicolas Cellier <[hidden email]>:
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.



Reply | Threaded
Open this post in threaded view
|

Re: Can we change the meaning of peekBack?

Nicolas Cellier



2014-07-28 21:46 GMT+02:00 Eliot Miranda <[hidden email]>:
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 <[hidden email]> 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 <[hidden email]>:
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.