inconsistent naming of Stream.sorted()?
Brian Goetz
brian.goetz at oracle.com
Thu May 23 08:30:59 PDT 2013
1. Because everything else in the library about sorting uses some form
of the word "sort"
2. Because "ordered" means something else!
An ordered stream is one which has a defined encounter order; that is,
one in which the order of elements is relevant. For example, a List has
a defined encounter order; a HashSet does not.
On 5/23/2013 11:15 AM, Lattie wrote:
> How about calling it ordered() if it is a property of the stream?
>
> On Thursday, May 23, 2013, Brian Goetz wrote:
>
> Sort of :)
>
> "sorted" is an adjective as well: "This list is sorted". This is a
> slightly different statement than "this list has been sorted", where
> sorted is used as a past participle.
>
> The intent of this naming choice was that the method would produce a
> stream that has the property of being sorted. In that way, it is
> consistent with:
>
> Stream.sequential()
> Stream.parallel()
> Stream.unordered()
> Stream.distinct()
>
> Granted, there are two subgroups here; one is sorted and distinct, where
> the named attribute describes the *elements*, and the others describe a
> property of the the *stream*, but I don't really see it as being
> inconsistent.
>
> I think calling it "sort" would be much worse. (Then we'd have to
> rename distinct to something like makeDistinct or removeDuplicates or
> filterDuplicates.)
>
> On 5/23/2013 10:40 AM, Gernot Neppert wrote:
> > Hi,
> >
> > I've been testing build 90 of JDK 1.8, and I came up with this
> question:
> >
> > Stream.sorted is the only method that uses the past participle
> form of the
> > verb that describes it.
> > All others, (such as filter, map, etc.) simply use the infinitive.
> >
> > Was this a deliberate decision or an an oversight?
> >
>
More information about the lambda-dev
mailing list