This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: question about "object"


Doug Orleans <dougo@ccs.neu.edu> writes:

> #|kawa:77|# (invoke (invoke (object () ((foo) int 3)) 'getClass) 'getDeclaredMethod "foo" #!null)
> <stdin>:77:2: warning - no possibly applicable method `getDeclaredMethod' in java.lang.Class
> public gnu.math.IntNum object.foo()
> (Not sure what the deal is with that warning message...)

It means the compiler cannot determine (at compile time) the specific method
that will be invoked.  The message should probably be supressed for
expressions typed at the command line ...  Also, sometimes it is just
that Kawa is too stupic about types.

"foo" should be 'foo, to get a Java string.  (It will get converted,
but it is mroe efficient to not do so.)

> Then I realized that "int" meant scheme ints,

Nope.  "int" is an undefined identifier in Kawa.
For Scheme integers, use <integer>.

> while the proper name for Java ints was "<int>":

Correct.

> Voila!  So here's the correct version of hashtable-key:
> 
> (define (hashtable-key list)
>   (object ()
>     ((hashCode) <int>

I prefer:

>     ((hashCode) :: <int>
> 
> Unfortunately, since it's an anonymous class, there's no way to cast
> the "obj" parameter to the right type before calling "getList" because
> we don't know the name of the class.  (The same problem would occur in 
> Java, except it would be an error, not just a warning...)  I guess I
> need to figure out how to define a module now.  (Or is "define-class"
> in the CVS version?)

Well, it is, but it doesn't do anything.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]