DSL for handle binding

Charles Oliver Nutter headius at headius.com
Sun Mar 20 23:21:19 PDT 2011


I'm working on a DSL for binding method handles *forward* rather than
backward. It's not much logic, really, but for me it's much easier to
reason about incoming arguments being transformed toward an eventual
target, rather than a target being transformed backward toward
incoming arguments. The API lets you bind like this:

MethodHandle mh = Binder
    .from(String.class, String.class, String.class) // (String, String)String
    .drop(1, String.class) // (String)String
    .insert(0, 'hello') // (String, String)String
    .cast(String.class, CharSequence.class, Object.class) //
(CharSequence, Object)String
    .invoke(someTargetHandle);

Is this interesting to others on the list? I will push my work to
github sooner rather than later if so. I plan to use this in JRuby to
make the MH binding code easier to read.

- Charlie


More information about the mlvm-dev mailing list