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: Kawa mailing list <kawa at sourceware dot org>
- Cc: mikel evins <mevins at me dot com>, Per Bothner <per at bothner dot com>
- Date: Tue, 13 May 2014 20:12:56 -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>
My question was in the subject line: what's the right way to compile and load modules. By "right" I mean a way that works both when batch-compiling kawa for packaging in a jar and when interactively loading sources for repl-session development.
The answer appears to be that for interactive loading, one should use a load file that consists of a series of require forms, one for each source file, and the load file should reside in the same directory as the sources. That approach loads all of our code and silences the warnings I was previously seeing. (I still see warnings about symbols that are not visibly referenced anywhere, but that is an accurate and informative warning, so I have no complaint).
For compiling, the answer is that each source file must have a module-export form that exports each symbol that is used in some other source file. That's contrary to what the kawa docs say, but I found that in practice I saw a number of problems if I didn't use module-export forms to expose a file's definitions. In some cases kawa refused to complete the compile; in others it built everything without complaint, but crashed into a stack trace at runtime on an undefined location.
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.