DSL for handle binding
Howard Lovatt
howard.lovatt at gmail.com
Tue Mar 22 16:27:58 PDT 2011
On 22 March 2011 12:13, Charles Oliver Nutter <headius at headius.com> wrote:
[snip]
>>
>> MethodHandle handle = Binder
>> .from(String.class, Integer.class, Float.class, String.class)
>> .invoke(target, Binder.arg(3), new File("foo"), Binder.arg(3));
A variation on this theme might be to support all 4 combinations below:
MethodHandle handleNumbered = Binder
.from( String.class, Integer.class, Float.class, String.class )
.bind( target, "3, %1, 3", new File( "foo" ) );
Binder binderNumbered = Binder
.from( String.class, Integer.class, Float.class, String.class )
.reorder( "3, %1, 3", new File( "foo" ) );
MethodHandle handleNamed = Binder
.return( String.class ).arg( "a", Integer.class ).arg( "b",
Float.class ).arg( "c", String.class )
.bind( target, "c, %1, c", new File( "foo" ) );
Binder binderNamed = Binder
.return( String.class ).arg( "a", Integer.class ).arg( "b",
Float.class ).arg( "c", String.class )
.reorder( "c, %1, c", new File( "foo" ) );
Just a thought,
-- Howard.
>
> Ahh, interesting ideas! Yes, the positional nature is probably the
> trickiest (especially when binding backward...I never get it right!)
> because of arguments moving around. I should probably see if there are
> other good language representations for list manipulation that make it
> clearer what's happening (and aren't as subject to elements moving).
>
> Another option might be a name/value representation of the incoming arguments?
>
> Binder
> .from(returns(String.class), arg("a", Integer.class), arg("b",
> Float.class), arg("c", String.class)
> .reorder("c", "c")
>
> Internally it would be juggling around pairs of name+type, so it would
> use the same identifier even if arguments shift around. The "a", "b",
> "c" could also be defaults, so that if you used the simple form:
>
> .from(String.class, Integer.class, Float.class, String.class)
>
> You could still use "c" to represent the String argument.
>
> - Charlie
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>
--
-- Howard.
More information about the mlvm-dev
mailing list