This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: the right way to compile and load modules
- From: mikel evins <mevins at me dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: mikel evins <mevins at me dot com>, kawa at sourceware dot org
- Date: Tue, 13 May 2014 21:05:28 -0500
- Subject: Re: the right way to compile and load modules
- Authentication-results: sourceware.org; auth=none
- References: <9F312D97-98C6-4F47-BDD9-B6CAF3868A28 at me dot com> <5371CFD0 dot 7070708 at bothner dot com> <7D1A5D60-5997-4B7A-9176-8F6FA315F016 at me dot com> <ED4375FE-30EE-4ABC-A9DC-2C6C4D67A87A at me dot com> <54132084-D633-4AAA-B2A4-9008FF37F779 at me dot com> <5372CA25 dot 7050602 at bothner dot com>
On May 13, 2014, at 8:43 PM, Per Bothner <per@bothner.com> wrote:
>>
>> Using module-export cures these symptoms.
>>
>> Since this is contrary to the kawa docs, I'm open to the possibility that I'm still doing something wrong that causes the unexpected behavior.
>
> I don't know. Sounds mysterious. If you have *no* module-exports it's supposed to be equivalent to
> exporting everything that isn't define-private etc. There are some exceptions - for examples names that
> are imported using require aren'r re-exported by default.Again, perhaps you can show us a simple test-case?
Two source files:
src/fact.scm:
(define (fact n)
(if (<= n 1)
1
(* n (fact (- n 1)))))
src/factest.scm:
(require "fact.scm")
(newline)
(display (fact 6))
(newline)
Ant build file in the directory that contains the src directory:
...
<path id="kawa.class.path">
<pathelement location="./lib/kawa-1.14.jar"/>
<pathelement path="."/>
</path>
...
<!--compile fact -->
<target name="fact">
<java taskname="kawa"
classname="kawa.repl"
failOnError="true"
dir="./src"
fork="true">
<classpath refid="kawa.class.path"/>
<arg line="-C 'fact.scm'"/>
</java>
</target>
<!--compile factest -->
<target name="factest" depends="fact">
<java taskname="kawa"
classname="kawa.repl"
failOnError="true"
dir="./src"
fork="true">
<classpath refid="kawa.class.path"/>
<arg line="--main -C 'factest.scm'"/>
</java>
</target>
Build results:
$ ant factest
Buildfile: /Users/mikel/Workshop/fabric/build.xml
fact:
[kawa] (compiling fact.scm to fact)
factest:
[kawa] (compiling factest.scm to factest)
[kawa] /Users/mikel/Workshop/fabric/src/fact.scm:3:9: warning - no use of fact
[kawa] factest.scm:3:1: warning - no declaration seen for fact
Run test:
$ java -cp src:lib/kawa-1.14.jar factest
factest.scm:3:1: unbound location fact
at gnu.mapping.SharedLocation.get(SharedLocation.java:22)
at gnu.mapping.ThreadLocation.get(ThreadLocation.java:105)
at factest.run(factest.scm:3)
at gnu.expr.ModuleBody.runAsMain(ModuleBody.java:152)
at factest.main(factest.scm)
BUILD SUCCESSFUL
Add a module-export form to fact.scm:
Build results:
$ ant factest
Buildfile: /Users/mikel/Workshop/fabric/build.xml
fact:
[kawa] (compiling fact.scm to fact)
factest:
[kawa] (compiling factest.scm to factest)
BUILD SUCCESSFUL
Run test:
$ java -cp src:lib/kawa-1.14.jar factest
720