On Sun, Apr 5, 2009 at 3:28 PM, Serabe <[email protected]> wrote:
> 2009/4/5 Thomas E Enebo <[email protected]>:
>> I would expect a type-error (compile-error?).  There are only three
>> arguments and this specifies four.  I think signatures need to map
>> straight through between Ruby and Java names.   How to bind to
>> restargs should probably default to <type>[] (e.g. String[]), but
>> perhaps there should be a way of assigning via collection types too
>> (perhaps as an option?).
>
> About mapping straight through, I answer with the one-to-one mapping below.
>
>
>> Introspecting Ruby method could give us knowledge of whether we need
>> restargs or not.
>
> Yes, of course, but if we let to asign more variables and map them
> into the restargs, an option to generate a signature with varargs
> should be added.
>
>> If you wanted to have a four argument string which fed into that
>> signature you need only add:
>>
>>  [java.lang.String,java.lang.String,java.lang.String,java.lang.String]
>> => Java::void
>> def foo4(a,b,c,d)
>>  foo(a,c,c,d)
>> end
>>
>> In general, I think having one-to-one mapping between variable names
>> will be less surprising to people.  It is easy to compose on Ruby side
>> (like in my example above) to have signatures which are not
>> one-to-one.
>
> I don't think a one-to-one mapping would be enough. For the example
> above, two methods would be generated, instead of one method
> overloaded. I rather have an overloaded method than two different
> methods with different names for the same functionality. Anyway, this
> lead us to being able to specify the java method name, something
> useful for getting getters. Both solutions seem fine to me, even if I
> prefer the first one, yours would add more naturaly the setting the
> java method name.

Yeah this is a good point.  You may want a larger universe of
overloaded signatures which will not map well from a possible set of
Ruby signatures to the Java side.  Certainly the possible Ruby
signatures are a subset of possible Java signatures.   Not sure I have
an answer for this at the moment.  Certainly, I am trying to reduce
the complexity as much as possible and the rock bottom is only
supporting Java signatures which Ruby signatures naturally support.
That is not enough if your use-case is to require a particular 'set'
of mappings for an API (and one or more signatures in that set are
like the ones you originally described).

It also makes me think that perhaps signatures should be able to
specify Java name with a mapping to the Ruby method it wants to
invoke.  This would be an entirely different way of supporting this
use case.  I am not saying this would be an ordinary front-end API
(though it could be part of a more complex one if need be), but it
would make it easy to have foo and foo2 bind to same Java method name
as different overloads.  I think we should start talking more about
how backend could satisfy these things and perhaps a font-end API will
come out of it naturally.

Another dimension of API signatures is annotations.  Those also can be
on one overloaded method signature or more.  Visibility also comes to
mind.   So multiple dimensions need to be supported.

-Tom

-- 
Blog: http://www.bloglines.com/blog/ThomasEEnebo
Email: [email protected] , [email protected]

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to