This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Question regarding modules and module-export in Kawa
- From: alex mitchell <alexm at nus dot edu dot sg>
- To: <kawa at sources dot redhat dot com>
- Date: Wed, 29 Apr 2009 10:46:31 +0800
- Subject: Question regarding modules and module-export in Kawa
Hi,
I'm trying to port some code from DrScheme to Kawa, and have run up against
issues with different behaviour of modules. I'm wondering if anyone can help
to clarify.
Here's a simple example of something I'm trying to get to work:
In moduletest.scm:
(module-export make-count)
; simple counter
(define (make-count)
(let ((count 0))
(lambda ()
(begin
(set! count (+ count 1))
(display count)))))
If I run this, I see the following warning:
#|kawa:1|# [...]/moduletest.scm:1:16: 'make-count' exported but never
defined
Despite this, the counter seems to work:
#|kawa:2|# #|kawa:3|# (define my-count (make-count))
#|kawa:4|# (my-count)
1
#|kawa:5|# (my-count)
2
However, if I require the module in another file, as follows:
(require "moduletest.scm")
(define my-count (make-count))
(my-count)
I get this:
#|kawa:1|# [...]/moduletest.scm:7:20: unbound location exception evaluating
count from Field:moduletest$frame.count - java.lang.NullPointerException
at gnu.expr.ReferenceExp.apply(ReferenceExp.java:106)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
at gnu.mapping.CallContext.getFromContext(CallContext.java:280)
at gnu.expr.Expression.eval(Expression.java:24)
at gnu.expr.ApplyExp.apply(ApplyExp.java:63)
[...]
at kawa.repl.main(repl.java:844)
I have a couple of questions. First, why am I getting the warning? I moved
the "module-export" below the definition of make-count, and still get this
warning. And second, why is count unbound in the second example? The
equivalent code works in DrScheme, so I'm probably just misinterpreting
something about how Kawa implements modules. Any clarification would be
greatly appreciated.
thanks!
Alex
alexm@nus.edu.sg