First draft of translation document

Brian Goetz brian.goetz at oracle.com
Thu May 20 08:32:34 PDT 2010


> With regard to the recent proposals, the advantages of interface
> injection are clear. I do not see any clear advantage to MethodHandle
> with bind for partial application (but maybe I'm just missing something)

Yes, you're missing something: optimization!

To take a simple example, lets say I have a function

   f(x, y) { if (x != null) x.foo() else y.foo() }

If I partially apply x, now x is a constant for purposes of compilation.  So 
if I partially apply a null x argument, the test and branch get 
dead-code-eliminated and it reduces to

   f(y) { y.foo() }

This may not seem like a big deal, but partial application gives the VM way 
more information -- type information, nullity information, array bounds 
information -- with which it can perform all sorts of optimizations (type 
sharpening which leads to better inlining, null check elimination, array 
bounds check elimination, dead code elimination, etc).



More information about the lambda-dev mailing list