PositionnableStream>>peekFor: not standard

Bert Freudenberg bert at freudenbergs.de
Thu Mar 1 11:24:03 UTC 2007


But why should there be a method #peekFor: if it does not more than  
#peek and #=? These two would do the same

	stream peekFor: $a
	stream peek = $a

That would be strange.

I don't find the name "peek" offensive in its current meaning. OTOH,  
if there was a better name for what it does, I'd not be violently  
opposed to changing it. As an aside, there is a similar method:

	stream match: 'a'

would do the same as the "advancing" #peekFor: but for a collection.

- Bert -

On Mar 1, 2007, at 1:57 , Ron Teitelbaum wrote:

> You know I still think it's wrong and should be implemented the way  
> the
> standard says.  Peek should peek regardless of how it is eventually  
> used and
> how all of the Smalltalk's implement it.  I can't be the only one  
> that saw
> it didn't work as expected and didn't use it because of that.   
> Notice that
> there are few senders of peekFor: and lots of senders of peek even  
> though
> many of the senders of peek are really peek fors.  Seems like a me-too
> implementation issue.
>
> I'll give you that the uses of peekFor: in the parsers are very  
> cleaver uses
> of peekFor:  (ex. negative := peekFor: $-. ) and I do get how and  
> why it's
> implemented the way it is but I still won't use it.
>
> I do agree, even though I won't use it, that it should be left the  
> way it is
> since it is consistent with all the other Smalltalks.  I wonder how  
> many
> other standards are not followed.  Did anyone check #isEmpty on
> PositionableStream?
>
> Ron Teitelbaum
>
>
>> From: Andreas Raab
>> Sent: Wednesday, February 28, 2007 5:23 PM
>>
>> 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
>>
>
>
>





More information about the Squeak-dev mailing list