PositionnableStream>>peekFor: not standard

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

Re: PositionnableStream>>peekFor: not standard

Bert Freudenberg

On Mar 1, 2007, at 15:44 , Ron Teitelbaum wrote:

> By the way match is not really the same:
>
> ('abc' copy readStream) match: 'b'; next => $c
>
> Since 'a' is not matched it advances until we find the collection.  
> This is
> really different from peek = $a since it flys past the next element  
> to find
> 'b'.

Ah, you're right.

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: PositionnableStream>>peekFor: not standard

stephane ducasse
In reply to this post by Andreas.Raab
does somebody has the latest version of the standard because the  
version we have is a beta from 1993?
After indeed this is strange that with such a consensus they got that  
because on the other part they made a good job.

Stef

On 28 févr. 07, at 23:23, Andreas Raab wrote:

> nicolas cellier wrote:
>> James Foster a écrit :
>>> Actually, in this case I'd suggest that we change the standard!  
>>> In each of
>>> the six Smalltalk dialects I have available (Dolphin, GemStone,  
>>> Squeak,
>>> VisualAge, VisualSmalltalk, VisualWorks) the following returns true:
>>>
>>>     ((ReadStream on: 'abc') peekFor: $a; next) = $b.
>>>
>> Also add stx (Smalltalk-X) and gst (GNU Smalltalk) to the list.
>
> I can't help but wonder how ANSI ended up with that definition if  
> basically every Smalltalk in existence does it differently. Just  
> one of those "design by committee" decisions? Or perhaps there is a  
> good reason for it that just never made the light of the day?  
> Mostly, the standards committee seemed to have gone with existing  
> notions if there wide agreement on them - peekFor: seems to be one  
> of those cases where the standard went wildly differently and I  
> really wonder why.
>
> Cheers,
>   - Andreas
>
>


Reply | Threaded
Open this post in threaded view
|

RE: PositionnableStream>>peekFor: not standard

jgfoster
The final standard is copyrighted and not freely available on the web.

gettableStream>>peek is described as follows:
"Returns the first object in the receiver's future sequence values. The
object is not removed from the future sequence values. The returned object
must conform to the receiver's sequence value type. Returns nil if the
receiver has no future sequence values. The return value will also be nil if
the first future sequence object is nil."

gettableStream>>peekFor: is described as follows:
"Returns the result of sending #= to the first object in the receiver's
future sequence values with anObject as the argument. Returns false if the
receiver has no future sequence values."

Note that while #peek explicitly says that the object is not removed, the
#peekFor: description does not discuss this question at all. To argue that
advancing the position is not standard is to argue from silence. I'd say
that the much better assumption is that this was simply an oversight and
that the intent of the committee was to document the universal
implementation of this method. (Note that the draft standard was widely
distributed and those of us following comp.lang.smalltalk at the time had a
chance to catch this omission. Calling this an oversight is not intended as
a criticism of those who worked quite hard on a generally very useful
document.)

James Foster

> -----Original Message-----
> From: [hidden email] [mailto:squeak-dev-
> [hidden email]] On Behalf Of stephane ducasse
> Sent: Thursday, March 01, 2007 1:56 PM
> To: The general-purpose Squeak developers list
> Subject: Re: PositionnableStream>>peekFor: not standard
>
> does somebody has the latest version of the standard because the
> version we have is a beta from 1993?
> After indeed this is strange that with such a consensus they got that
> because on the other part they made a good job.
>
> Stef
>


Reply | Threaded
Open this post in threaded view
|

Re: PositionnableStream>>peekFor: not standard

stephane ducasse

On 2 mars 07, at 01:26, James Foster wrote:

> The final standard is copyrighted and not freely available on the web.

But could we get it via an obscure place :)

>
> gettableStream>>peek is described as follows:
> "Returns the first object in the receiver's future sequence values.  
> The
> object is not removed from the future sequence values. The returned  
> object
> must conform to the receiver's sequence value type. Returns nil if the
> receiver has no future sequence values. The return value will also  
> be nil if
> the first future sequence object is nil."
>
> gettableStream>>peekFor: is described as follows:
> "Returns the result of sending #= to the first object in the  
> receiver's
> future sequence values with anObject as the argument. Returns false  
> if the
> receiver has no future sequence values."
>
> Note that while #peek explicitly says that the object is not  
> removed, the
> #peekFor: description does not discuss this question at all. To  
> argue that
> advancing the position is not standard is to argue from silence.  
> I'd say
> that the much better assumption is that this was simply an  
> oversight and
> that the intent of the committee was to document the universal
> implementation of this method. (Note that the draft standard was  
> widely
> distributed and those of us following comp.lang.smalltalk at the  
> time had a
> chance to catch this omission. Calling this an oversight is not  
> intended as
> a criticism of those who worked quite hard on a generally very useful
> document.)
>
> James Foster
>
>> -----Original Message-----
>> From: [hidden email] [mailto:squeak-
>> dev-
>> [hidden email]] On Behalf Of stephane ducasse
>> Sent: Thursday, March 01, 2007 1:56 PM
>> To: The general-purpose Squeak developers list
>> Subject: Re: PositionnableStream>>peekFor: not standard
>>
>> does somebody has the latest version of the standard because the
>> version we have is a beta from 1993?
>> After indeed this is strange that with such a consensus they got that
>> because on the other part they made a good job.
>>
>> Stef
>>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: PositionnableStream>>peekFor: not standard

J J-6
In reply to this post by Damien Cassou-3

You don't mean writing tests that are red on purpose I hope. :)

>From: "Damien Cassou" <[hidden email]>
>Reply-To: The general-purpose Squeak developers
>list<[hidden email]>
>To: "The general-purpose Squeak developers
>list"<[hidden email]>
>Subject: Re: PositionnableStream>>peekFor: not standard
>Date: Thu, 1 Mar 2007 11:12:52 +0100
>
>As usually, we all have different opinions :-)
>
>Since most Smalltalks have the same #peekFor: implementation, I won't
>touch it. However, I will explicitely explain the problem in the
>comment and write tests.
>
>If some of you want, I can create a new method with the standard
>implementation. You just need to give me a name. I will write tests
>and a comment.
>
>--
>Damien Cassou
>

_________________________________________________________________
Play Flexicon: the crossword game that feeds your brain. PLAY now for FREE. 
  http://zone.msn.com/en/flexicon/default.htm?icid=flexicon_hmtagline


Reply | Threaded
Open this post in threaded view
|

Re: PositionnableStream>>peekFor: not standard

Damien Cassou-3
I mean writing tests verifying the behavior I choosed :-)

2007/3/6, J J <[hidden email]>:

>
> You don't mean writing tests that are red on purpose I hope. :)
>
> >From: "Damien Cassou" <[hidden email]>
> >Reply-To: The general-purpose Squeak developers
> >list<[hidden email]>
> >To: "The general-purpose Squeak developers
> >list"<[hidden email]>
> >Subject: Re: PositionnableStream>>peekFor: not standard
> >Date: Thu, 1 Mar 2007 11:12:52 +0100
> >
> >As usually, we all have different opinions :-)
> >
> >Since most Smalltalks have the same #peekFor: implementation, I won't
> >touch it. However, I will explicitely explain the problem in the
> >comment and write tests.
> >
> >If some of you want, I can create a new method with the standard
> >implementation. You just need to give me a name. I will write tests
> >and a comment.
> >
> >--
> >Damien Cassou
> >
>
> _________________________________________________________________
> Play Flexicon: the crossword game that feeds your brain. PLAY now for FREE.
>   http://zone.msn.com/en/flexicon/default.htm?icid=flexicon_hmtagline
>
>
>


--
Damien Cassou

12