This is the mail archive of the kawa@sourceware.org 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]

Module Import Bindings for Non-Main Classes


Hi everybody, another question; this time about importing module fields. Suppose I have the following:



;; alpha.scm

(module-name "com.example.Alpha")

(define (test-a) (format #t "inside test-a~%"))
(define (make-test-b) (lambda () (format #t "inside test-b~%")))
(define test-b (make-test-b))
(define test-c 42)



;; beta.scm

(module-name "com.example.Beta")

(import (only (com example Alpha) test-a test-b test-c))

(define (test)
  (display test-a) (newline)
  (display test-b) (newline)
  (display test-c) (newline))

(test)



;; gamma.scm

(module-name "com.example.Gamma")

(com.example.Beta:test)



I'll compile these into classes.



$ rm -rf classes/
$ mkdir classes
$ CLASSPATH='classes' kawa -d classes -C alpha.scm
$ CLASSPATH='classes' kawa -d classes --main -C beta.scm
$ CLASSPATH='classes' kawa -d classes --main -C gamma.scm



Now I try to run Gamma and Beta, getting different results:



$ java -cp lib/kawa-1.11.jar:classes 'com.example.Beta'
#<procedure test-a>
#<procedure alpha.scm:4>
42
$ java -cp lib/kawa-1.11.jar:classes 'com.example.Gamma'
#<procedure test-a>
#!null
#!null



Why are test-b and test-c bound to the values they have in Alpha only when running Beta as the main class? How can I get the "right" bindings when running Gamma as the main class? I must be missing something obvious, but I can't figure it out. Thank you for any advice.

Kawa from SVN trunk at r7076
GNU/Linux x86_64 (Arch)
OpenJDK 6 b22

--
Taylor ChriÅtopher Venable
Senior Programmer/Analyst
IPFW IT Services KT 204K / 209A
2101 E. Coliseum Blvd.
Fort Wayne, IN 46805
260-481-0720


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