PositionnableStream>>back behavior?

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

PositionnableStream>>back behavior?

Damien Cassou-3
Hi,

I don't really understand why #back goes two step backward:

stream := ReadStream on: 'abc' copy.
stream next.
stream next.
stream peek.       ==> $c
stream back.       ==> $a

If the following character is $c then the previous one should be $b.
Don't you think so?

Bye

--
Damien Cassou

Reply | Threaded
Open this post in threaded view
|

Re: PositionnableStream>>back behavior?

timrowledge

On 6-Apr-07, at 8:08 AM, Damien Cassou wrote:

> Hi,
>
> I don't really understand why #back goes two step backward:
>
> stream := ReadStream on: 'abc' copy.
> stream next.
> stream next.
> stream peek.       ==> $c
> stream back.       ==> $a
>
> If the following character is $c then the previous one should be $b.
> Don't you think so?

If current char is$b, then next is $c and previous is $a.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful random insult:- If you stand close enough to him, you can hear  
the ocean



Reply | Threaded
Open this post in threaded view
|

Re: PositionnableStream>>back behavior?

Damien Cassou-3
2007/4/6, tim Rowledge <[hidden email]>:

>
> On 6-Apr-07, at 8:08 AM, Damien Cassou wrote:
>
> > Hi,
> >
> > I don't really understand why #back goes two step backward:
> >
> > stream := ReadStream on: 'abc' copy.
> > stream next.
> > stream next.
> > stream peek.       ==> $c
> > stream back.       ==> $a
> >
> > If the following character is $c then the previous one should be $b.
> > Don't you think so?
>
> If current char is$b, then next is $c and previous is $a.

Ok :-) I didn't know there were a notion of current element. I thought
a stream was always between two elements; and there is no notion of
current in ANSI Smalltlalk.

Thank you


--
Damien Cassou

Reply | Threaded
Open this post in threaded view
|

Re: PositionnableStream>>back behavior?

Mathieu SUEN
In reply to this post by timrowledge
yep but  peek return the current char. Isn't it?

On Apr 6, 2007, at 5:39 PM, tim Rowledge wrote:

> if current char is$b, then next is $c and previous is $a.

        Mth




Reply | Threaded
Open this post in threaded view
|

Re: PositionnableStream>>back behavior?

Damien Cassou-3
2007/4/6, Mathieu Suen <[hidden email]>:
> yep but  peek return the current char. Isn't it?

According to what I understand:

- #peek returns the next element
- #back returns the previous element
- #last returns the current one (what a great name, isn't it?)

--
Damien Cassou