This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
RE: difference between (load "package.foo.bar") and require?
- From: "Dominique Boucher" <dominique dot boucher at nuecho dot com>
- To: "'Hoehle, Joerg-Cyril'" <Joerg-Cyril dot Hoehle at t-systems dot com>, <kawa at sources dot redhat dot com>
- Date: Thu, 27 May 2004 11:29:32 -0400
- Subject: RE: difference between (load "package.foo.bar") and require?
- Reply-to: <dominique dot boucher at nuecho dot com>
Joerg-Cyril,
The semantics of (load "file") and (require <modulename>) is quite different
and serves different purposes.
When loading a file, all top-level definitions are added to the top-level
interaction environment. The loading is done by 'load' using a custom class
loader. That's why it does not take into account the .jar files.
When requiring a module B from a module A, you make the exported bindings of
B visible to the importing module (A). This has nothing to do with the
top-level environment. This is mainly to produce more efficient code. At
runtime, module A will make sure that module B is loaded, using the usual
class loading mechanism. If your code is in a .jar file, and the .jar file
is in your classpath, it will load like any other Java file.
If you want to access some loaded code from within Kawa modules compiled
using kawa -C, you'll have to use 'eval'.
Regards,
Dominique Boucher
> -----Original Message-----
> From: kawa-owner@sources.redhat.com
> [mailto:kawa-owner@sources.redhat.com] On Behalf Of Hoehle,
> Joerg-Cyril
> Sent: 27 mai 2004 11:06
> To: kawa@sources.redhat.com
> Subject: difference between (load "package.foo.bar") and require?
>
> Hi,
>
> I'm running into several problems with load/require, .class
> and .jar files, and I'll try to post items separately.
>
> It appears that
> (load "package.misc.foo")
> does not look into .jar files, and only loads .class files
> found in package/misc/foo[$frameN].class.
>
> OTOH (require <package.misc.foo>) does look into .jar files.
>
> But so far I haven't managed to load or require Scheme files
> compiled via --module-static -C *.scm from a .jar file:
>
> There seems to be things going on which I don't understand,
> which appear like each require using its own namespace or
> something like that, so I get unbound variable errors when
> referencing one variable from another compiled .scm->class file.
> I'll post more no this separate item later on.
>
> Thanks for your help,
> Jorg Hohle.
>