PositionnableStream>>peekFor: not standard
Ron Teitelbaum
Ron at USMedRec.com
Thu Mar 1 14:44:41 UTC 2007
Hi Bert,
I get that #peekFor: that doesn't advance is the same as #peek #=. That's
why it was easy for me to get what I was looking for without using peekFor:
. I also agree that we could leave it the way it is, since it is supported
in all smalltalks in its current implementation. I suppose my objection is
just a personal taste issue. I won't use it because it just makes more
sense to me to use #peek #= then #next.
Although I did think
isNegative := aStream peekFor: $-.
was very nice and did make the code cleaner.
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'.
Ron Teitelbaum
> From: Bert Freudenberg
> Sent: Thursday, March 01, 2007 6:24 AM
>
> 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
|