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]

Warning elimination


Dear Per Bothner and list members,

I'm new to Kawa but am already impressed with its implementation and
superb integration with the Java Virtual Machine.

I'm wondering if there is a way to eliminate the "no definitely
applicable method `<init>' in java.io.File" when loading this seemingly
innocuous function from the REPL:

(define (file-date file)
  (java.io.File:lastModified
    (if (string? file) (make 'java.io.File file) file)))

It appears I need to declare the input type of argument `file' as
<string> or <java.io.File>, and I don't believe that declaring types as
sets are supported in Kawa.

The version below contains enough information for a compiler to deduce
that `object' only evaluates to a <java.io.File> type (this would be
easier for the compiler to deduce if a `type?' function was standard):

(define (file-date file)
  (let ((object (cond ((string? file)
                       (make 'java.io.File file))
                      ((eq? (java.lang.Class:getName
                             (java.lang.Object:getClass file))
                            'java.io.File)
                       file)
                      (else (error "file-date; illegal type:" file)))))
    (java.io.File:lastModified object)))

Obviously this warning isn't a showstopper. I'd just like to know how to
suppress it in the event it's a spurious warning or how to write this
function correctly to eliminate the warning.

Regards,
Adam Warner


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