This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Re: unusual type conversion in invoke
- From: Vladimir Tsichevski <wowa1 at online dot ru>
- To: kawa at sources dot redhat dot com
- Date: Sat, 05 Apr 2003 23:37:28 +0400
- Subject: Re: Re: unusual type conversion in invoke
- Organization: Jet
- Reply-to: wowa1 at online dot ru
Hi Per,
here is more annoying situation:
wowa at src$ cat Test.scm
(invoke(make <java.lang.StringBuffer>) 'append (as <int> 10))
wowa at src$ kawa -C Test.scm
(compiling Test.scm)
Test.scm:3:2: warning - more than one definitely applicable method
`append' in java.lang.StringBuffer
Test.scm:3:2: warning - candidate: java.lang.StringBuffer
java.lang.StringBuffer.append(double)
Test.scm:3:2: warning - candidate: java.lang.StringBuffer
java.lang.StringBuffer.append(float)
Test.scm:3:2: warning - candidate: java.lang.StringBuffer
java.lang.StringBuffer.append(long)
Test.scm:3:2: warning - candidate: java.lang.StringBuffer
java.lang.StringBuffer.append(int)
Test.scm:3:2: warning - candidate: java.lang.StringBuffer
java.lang.StringBuffer.append(char)
Test.scm:3:2: warning - candidate: java.lang.StringBuffer
java.lang.StringBuffer.append(boolean)
Test.scm:3:2: warning - candidate: java.lang.StringBuffer
java.lang.StringBuffer.append(java.lang.Object)
Test.scm:3:2: warning - candidate: java.lang.StringBuffer
java.lang.StringBuffer.append(java.lang.String)
wowa at src$
Kawa refuses to accept a method which signature *exactly* matches the
type of its argument.
the problem is that this time I do not know how to work this around :-(
Regards,
Vladimir
>Vladimir Tsichevski wrote:
>
>> Hi all,
>>
>> just discovered an unusual time conversion kawa implicitly does when
looking for
>> appropriate method to invoke.
>>
>> the following line:
>>
>> (invoke 'abcd 'indexOf 10)
>>
>> compiles to:
>>
>> "abcd".indexOf("10");
>>
>> i.e. the number 10 becomes the string "10".
>>
>> a workaround is to explicitly defining the type of constant:
>>
>> (invoke 'abcd 'indexOf (as <int> 10))
>>
>> but I cannot imagine the situation when such implicitly conversion
might be useful :-(
>
>
>What's happening is that String.indexof(String) is considered
>"definitely applicable" (any object can be converted to a
>string using toString), while String.indexOf(int) applied
>to a gnu.math.IntNum is "conditionally applicable" (since
>the runtime value may be too large. And the method selection
>code prefers methods that are definitely applicable.
>
>
>One could argue about whether the toString conversion should
>be automatic, but it should certainly be lower priority.
>We might want some types (as least Scheme strings) to be
>automatically converted to Java Strings.
>--
> --Per Bothner
>per at bothner dot com http://per.bothner.com/
>