This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Questions regarding modules
- From: Per Bothner <per at bothner dot com>
- To: Marius Kjeldahl <marius dot kjeldahl at gmail dot com>, kawa at sourceware dot org
- Date: Mon, 03 Mar 2014 12:30:13 -0800
- Subject: Re: Questions regarding modules
- Authentication-results: sourceware.org; auth=none
- References: <CAHdMyCJYL=6YJ0oT1pbLdA57kGRCXMRVM1QxyfWar0pzErYsrw at mail dot gmail dot com> <531267B8 dot 6040407 at bothner dot com> <53144610 dot 9040207 at bothner dot com> <CAHdMyCJYH4AnZJS8pKxJ+YOo51DJBOw9a6rJQqwVYv-LxTjPsQ at mail dot gmail dot com>
On 03/03/2014 01:23 AM, Marius Kjeldahl wrote:
If it's a bug than certainly explains my struggles.
I can confirm that the import statement does not trigger the error
that the similar require statement does. However I am still unable to
access the "hello" function from KawaHello (when using the
module-name/define pattern) using net.kjeldahl.kawatest.app.KawaHello.
The same "no known slot hello in java.lang.Object" warning gets
triggered.
Replace:
(HelloKawa:hello)
by plain:
(hello)
or:
(net.kjeldahl.kawatest.app.HelloKawa:hello)
Remember what I wrote March 1:
When you (require MODULE) what happens is that all the public (exported)
names in MODULE are added to the current lexical scope.
If you write:
(module-name net.kjeldahl.kawatest.app.HelloKawa)
(define (hello)
"Hello from Kawa!")
then HelloKawa is *not* a public exported name in the module,
so it is *not* in scope in KawaActivity (or in HelloKawa).
Kawa's default binding mechanism does add bindings for all
fully-qualified class names that exist in the classpath.
The is why you can write things like (java.util.ArrayList).
The binding is a default (fall-back), so it only triggers only
if there is no binding in the lexical scope.
However, HelloKawa is not a fully-qualified class name. For that
you have to write:
(net.kjeldahl.kawatest.app.HelloKawa:hello)
Best is to write plain:
(hello)
--
--Per Bothner
per@bothner.com http://per.bothner.com/