For a numeric intensive code I have written a function with the following signature:
def update( f: (Int,Int,Double) => Double ): Unit = {...}
About the anonymous class which extends Function3
(the bytecode of which you show) generated by Scalac - it is not possible to call the overloaded apply
with primitive parameters from within the b.update
, because that update
method takes a Function3
, which does not have an apply
with primitive parameters.
From within the Function3
bytecode, the only apply
is:
public abstract java.lang.Object apply(java.lang.Object, java.lang.Object, java.lang.Object);
You could instead use Function2[Long, Double]
, which is specialized on those types, and encode 2 integers x
and y
in a long as (x.toLong << 32) + y
, and decode them as v & 0xffffffff
and (v >> 32) & 0xffffffff
.