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]
Other format: [Raw text]

Re: warnings when calling methods from Java interfaces, not classes


Hi,

thanks for the many things I learnt from Per's answer:

1. By using begin around define, definitions therein get compiled together even in Scheme (load "foo.scm") mode. As a result, Kawa thus knows more about parameter and return types.

2. It's possible to use interfaces in type declarations, not just classes, e.g.:
  (let* ((pubkey :: <java.security.interfaces.RSAPublicKey> ...)

3. alternative syntax for type declarations:
> (define (bigint-n-bytes n big :: <java.math.BigInteger>)
>   (invoke big 'toByteArray))
I only knew
(define (bigint-n-bytes n (big :: <java.math.BigInteger>))
but it's right that the BNF in kawa/Procedures.html covers this alternate form.

It's always nice when features are at least covered by an example, if not explicit text, not just hidden in a BNF. I recommend to add one such example somewhere (e.g. Procedures.html)

BTW, on page kawa/Declaring-Types-of-Variables.html
it would be nice if references to define-private and -constant were clickable links.


4. how to declare return types?
>It's best to explicitly specify the return type as <byte[]>,
How to do that? By using an explicit cast on each value returning expression inside the lambda?
e.g. (as <byte[]> (invoke big 'toByteArray))


5.
> I go back and forth on 
>whether Kawa should attempt to infer return types of functions 
>and just 
>use <object> if it isn't declared.  The problem is that until Kawa has 
>solid and consistent typechecking it's hard to specify under which 
>circumstances Kawa can infer a return type, and it is important that 
>this be consistent because it is wired into the Java method type.

One problem I see is with trying to be too smart: what would be the consequence if a function foo where redefined later, with different types?
This matters in an interactive environment.

Remembers me of the problem with
(define bar (lambda (str . max-no-char)
  (set! max-no-char (if (null? max-no-char) #f (car max-no-char)))
  (list str max-no-char))
that you just seem to have fixed (I haven't tried out CVS).

>If you declare bigint-n-bytes before rnd-pkcs1 and compile then as a 
>file, then Kawa knows the return type of bigint-n-bytes.
>It works when compiling as a module.  Compiling with with -C 
>produces no warnings:

Thanks for all this information!

Regards,
	Jorg Hohle.


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