Re: MethodHandle loop body parameters and Stream.reduce accumulator parameters are not in the same order

2016-09-20 Thread Michael Haupt
Hi Rémi,

I think you can stay tuned for the fix to JDK-8151179; part of what it 
addresses is just this. The changes are currently in the CCC loop but should 
come up for public re-review soon.

Best,

Michael

> Am 14.09.2016 um 15:19 schrieb Remi Forax :
> 
> 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 reduce(U identity,
> BiFunction accumulator,
> BinaryOperator 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

-- 

 
Dr. Michael Haupt | Principal Member of Technical Staff
Phone: +49 331 200 7277 | Fax: +49 331 200 7561
Oracle Java Platform Group | LangTools Team | Nashorn
Oracle Deutschland B.V. & Co. KG | Schiffbauergasse 14 | 14467 Potsdam, Germany

ORACLE Deutschland B.V. & Co. KG | Hauptverwaltung: Riesstraße 25, D-80992 
München
Registergericht: Amtsgericht München, HRA 95603

Komplementärin: ORACLE Deutschland Verwaltung B.V. | Hertogswetering 163/167, 
3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Nederland, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Jan Schultheiss, Val Maher
  Oracle is committed to developing 
practices and products that help protect the environment

___
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev


MethodHandle loop body parameters and Stream.reduce accumulator parameters are not in the same order

2016-09-14 Thread Remi Forax
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 reduce(U identity,
 BiFunction accumulator,
 BinaryOperator 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