This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
(this) and modules
- From: "Dominique Boucher" <dboucher at nuecho dot com>
- To: "Kawa List" <kawa at sources dot redhat dot com>
- Date: Fri, 26 Sep 2003 15:42:52 -0400
- Subject: (this) and modules
Hi,
I'm currently experimenting with the definition of modules with
non-static fields/functions (in order to use the module as a class). I
stumbled across two warnings that (I think) can be easily eliminated.
Consider the following code:
-------------------
(module-name <Test>)
(module-static #f)
(define (foo)
(invoke (this) 'bar))
(define (bar)
(format #t "Hello!~%"))
-------------------
When I compile this code using Kawa 1.7, I get:
(dboucher@Forman) (15:28:42) [tmp] kawa -C test.scm
(compiling test.scm)
test.scm:5:4: warning - no method `bar' in java.lang.Object
test.scm:5:12: warning - use of 'this' not inside a class
I can get rid of the first warning by explicitely casting (this) to
<Test>:
(define (foo)
(invoke (as <Test> (this)) 'bar))
But I can't get rid of the other warning. But the program works ok. It
seems that, if the module is compiled as a class, then (this) shall be
properly defined in a non-static function/method and the compiler shall
not issue a warning. Am I right? [Maybe there are some issues that I am
unaware...]
Also, can't the compiler assume that (this) returns an object of the
class being defined?
Regards,
Dominique Boucher