Static methods on Stream and friends

Ali Ebrahimi ali.ebrahimi1781 at gmail.com
Sun Apr 21 14:05:19 PDT 2013


Hi,

don't you think varargs version support the two others?


On Sun, Apr 21, 2013 at 11:05 PM, Brian Goetz <brian.goetz at oracle.com>wrote:

> Two things here:
>
> 1.  Tim may be suggesting to go further and rename "Stream.empty" to
> "Stream.of()"?
>
> 2.  Query about method selection.
>
> Method selection proceeds in three phases (see JLS 7/e 15.12.2):
>
>   1.  no boxing or unboxing
>   2.  with boxing/unboxing, but no varargs
>   3.  with varargs.
>
> So, Stream.of(T) will be considered before Stream.of(T...) is -- even for
> boxed streams like Stream<Integer>.  So I believe there is no need to
> extend the variable arity signature to of(T, T, T...).
>
>
> On 4/21/2013 2:30 PM, Tim Peierls wrote:
>
>> On Sun, Apr 21, 2013 at 2:19 PM, Brian Goetz <brian.goetz at oracle.com
>> <mailto:brian.goetz at oracle.com**>> wrote:
>>
>>     It was suggested on lambda-dev that we should rename singleton to
>>     simply be an overload of "of":
>>
>>        Stream.of(T)
>>        Stream.of(T...)
>>
>>     which seems reasonable.
>>
>>
>> Aren't there ambiguity problems with that pair of signatures? I would
>> have thought something like this:
>>
>> Stream.of() // for empty
>> Stream.of(T) // for singleton
>> Stream.of(T, T, T...) // for two or more
>>
>> --tim
>>
>


More information about the lambda-libs-spec-observers mailing list