Hi everybody,
i've just found that the parameters of the body (a MethodHandle) of 
MethodHandles.countedLoop (both overloads) and iteratedLoop are not in the same 
order as the accumulator in methods Stream.reduce, given that they conceptually 
represent the same thing, i think the first two parameters of body should be 
swapped in countedLoop and iteratedLoop.

in Stream:
<U> U reduce(U identity,
             BiFunction<U,? super T,U> accumulator,
             BinaryOperator<U> combiner)
 so this is equivalent to value = accumulator(value, element)

In MethodHandles:
   MethodHandle iteratedLoop(MethodHandle iterator,
                             MethodHandle init,
                             MethodHandle body)
  with value = body(element, value, iterable)
it should be
  value = body(value, element, iterable).

Same things for 
   MethodHandle countedLoop(MethodHandle start,
                            MethodHandle end,
                            MethodHandle init,
                            MethodHandle body)  
  it should be
    value = body(value, index, array); 
  instead of
    value = body(index, value, array);

the other loop combinators do not be to be changed.

cheers,
Rémi
_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to