DSL for handle binding
John Rose
john.r.rose at oracle.com
Mon Mar 21 15:42:08 PDT 2011
On Mar 21, 2011, at 3:24 PM, Charles Oliver Nutter wrote:
> I did get reorder in, and it's far easier for me to follow when
> explicitly going forward:
>
> MethodHandle handle = Binder
> .from(String.class, Integer.class, Float.class, String.class)
> .drop(0, 2)
> .reorder(0, 0)
> .invoke(target);
>
> ...with the end target having a signature of (String, String)String.
> My brain is happy.
The small integers are a little hard to decode since they shift from step to step. In the above case, I think you don't need the explicit drop:
MethodHandle handle = Binder
.from(String.class, Integer.class, Float.class, String.class)
.reorder(3, 3)
.invoke(target);
Also, some users (including Ola, I think) have requested a combined transform which (a) drops, (b) permutes, and (c) introduces bound values. With Binder it would look like one of these:
MethodHandle handle = Binder
.from(String.class, Integer.class, Float.class, String.class)
.reorder(Binder.arg(3), new File("foo"), Binder.arg(3))
.invoke(target);
which ends with type signature (String, File, String)String. Or even:
MethodHandle handle = Binder
.from(String.class, Integer.class, Float.class, String.class)
.invoke(target, Binder.arg(3), new File("foo"), Binder.arg(3));
-- John
More information about the mlvm-dev
mailing list