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 03:40:33 -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>
On May 13, 2014, at 3:01 AM, mikel evins <mevins@me.com> wrote:
>> A possible problem is that load is line-by-line, which is fundamentally
>> incompatible with modules as a unit - and thus with export. If you use
>> load, leave off the exports.
>
> If I leave off the exports I cannot compile.
>
> I can try requiring or importing from the repl and see how that works
Okay, that didn't work out so well.
I've been using load because a couple of people are working on this project and the exact paths to the sources are not going to be the same across machines. It's convenient to use load because I can simply find out the path to the load file at launch time and then compute the pathnames to all the sources, then for-each over those paths to load them.
That doesn't work the same way with import or require, since they're syntax and don't evaluate their arguments.
How can I make a system load file that will import or require all of the sources of a project into an interactive session without using load?
This does not work:
(define (load-client)
(require "/Users/mikel/Workshop/fabric/scm/src/invoke.scm"))
...yielding an error like this:
#|kawa:1|# #|kawa:2|# cannot find module invoke
at gnu.expr.ModuleContext.findInstance(ModuleContext.java:55)
at gnu.expr.ModuleInfo.getInstance(ModuleInfo.java:272)
at kawa.standard.require.find(require.java:120)
at atInteractiveLevel$7.loadClient(load-fabric.scm:62)
at atInteractiveLevel$7.apply0(load-fabric.scm:61)
at gnu.expr.ModuleMethod.apply0(ModuleMethod.java:186)
at gnu.expr.ModuleMethod.apply(ModuleMethod.java:160)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:373)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:210)
at kawa.Shell.run(Shell.java:279)
at kawa.Shell.run(Shell.java:194)
at kawa.Shell.run(Shell.java:175)
at kawa.repl.main(repl.java:871)
I can load the file interactively at the repl, but loading a few dozen files interactively at the repl every time I start a session is going to be a non-starter.