On Sun, 5 Nov 2023 16:38:38 GMT, Tagir F. Valeev <tval...@openjdk.org> wrote:

>> Viktor Klang has updated the pull request incrementally with two additional 
>> commits since the last revision:
>> 
>>  - Addressing review feedback
>>  - Make Gatherer.andThen take a wildcard for the rhs Gatherer state type
>
> src/java.base/share/classes/java/util/stream/Gatherer.java line 272:
> 
>> 270:      * Returns a combiner which is the default combiner of a Gatherer.
>> 271:      * The returned combiner identifies that the owning Gatherer must 
>> only
>> 272:      * be evaluated sequentially.
> 
> Should we specify that a single shared instance is guaranteed to be returned, 
> so clients may use `combiner == defaultCombiner()`, rather than 
> `combiner.equals(defaultCombiner())`?

@amaembo Something to the effect of "This method always returns the same 
instance."?

> src/java.base/share/classes/java/util/stream/Gatherer.java line 351:
> 
>> 349:      * @return the new {@code Gatherer}
>> 350:      */
>> 351:     static <T, A, R> Gatherer<T, A, R> ofSequential(
> 
> There are two two-function overloads:
>> ofSequential(Integrator<Void, T, R>, BiConsumer<Void, Downstream<? super R>>)
> and
>> ofSequential(Supplier<A>, Integrator<A, T, R>)
> 
> While the functional parameters have clearly different signatures, and one 
> will have no problems with lambdas, it's possible that resolve will fail if 
> you use overloaded method references:
> 
>> ofSequential(A::b, C::d)
> 
> Assume that there are several A::b and C::d methods accepting different 
> number of parameters. In this case, one cannot use method references. This is 
> probably a minor problem, but I prefer to avoid overloads accepting the same 
> number of functions. Probably we may use more descriptive names, like 
> `ofSequentialStateless` for stateless overloads?

I tried several variations of overloading vs specific names, and beyond 2 
different names it started to become more confusing than helpful. Any Gatherer 
can have a Void state type.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16420#discussion_r1387197102
PR Review Comment: https://git.openjdk.org/jdk/pull/16420#discussion_r1387194366

Reply via email to