This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: kawa-java string compatibility proposal
- From: Per Bothner <per at bothner dot com>
- To: Steve Yegge <steve dot yegge at gmail dot com>
- Cc: kawa at sources dot redhat dot com
- Date: Thu, 03 Mar 2005 00:20:36 -0800
- Subject: Re: kawa-java string compatibility proposal
- References: <d494cb8f0503022155795d9eee@mail.gmail.com>
Steve Yegge wrote:
The only glitch in this otherwise very convenient behavior occurs
when a Java method expects a CharSequence, which is a relatively
new superinterface of java.lang.String. In that case, Kawa doesn't
perform the conversion:
(let ((pattern (java.util.regex.Pattern:compile "(f+)(o+)")))
(invoke pattern 'matcher "foo"))
If you configure CVS Kawa with --select-java5, it works:
#|kawa:1|# (let ((pattern (java.util.regex.Pattern:compile "(f+)(o+)")))
(invoke pattern 'matcher "foo"))
java.util.regex.Matcher[pattern=(f+)(o+) region=0,3 lastmatch=]
The default "select" is "java2" - which means "jdk 1.2". I could
define an option for "jdk 1.4" but I don't think it's worth it.
For now I think jdk 1.2 (intersected with gcj/classpath) is a
reasonable default. Unfortunately, you can't use the same Kawa
source for jdk 1.4 and jdk 1.5.
Argument #1 ((f+)(o+)) to
'java.util.regex.Pattern.matcher(java.lang.CharSequence)' has wrong type
(java.util.regex.Pattern) (expected: java.lang.CharSequence)
The error message above seems a bit confused; the argument is a
gnu.lists.FString.
Kawa was somewhat inconsistent argument numbering, sometimes
starting at 1 and sometimes at 0. That has been fixed
in CVS Kawa:
<unknown>:0: warning - cannot convert literal (of type
gnu.lists.FString) to java.lang.CharSequence
Argument #2 (foo) to
java.util.regex.Pattern.matcher(java.lang.CharSequence)'
has wrong type (gnu.lists.FString)
(Argument #1 is the 'this' argument.)
We might be able to make the behavior fully seamless by having
gnu.lists.FString implement CharSequence. There are only four
methods on CharSequence, and FString already implements three of
them. The fourth is the subSequence() method, which could simply
call substring() and return the result.
Fixed in CVS - if you configure with --select-java5 .
More later.
--
--Per Bothner
per@bothner.com http://per.bothner.com/