This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: loading files locally
- To: Klaus.Schilling AT home.ivm.de
- Subject: Re: loading files locally
- From: Mikael Djurfeldt <mdj AT mdj-pc.nada.kth.se>
- Date: 16 Sep 1999 18:48:39 +0200
- Cc: guile AT sourceware.cygnus dot com, djurfeldt AT nada.kth.se
- Cc: djurfeldt AT nada.kth.se
- References: <m11RkMn-000H3wC@debian> <xy7ogf295cg.fsf@mdj-pc.nada.kth.se>
Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se> writes:
> Klaus Schilling <Klaus.Schilling@home.ivm.de> writes:
>
> > is there a way to load files in a way that they get evaluated
> > in the current environment instead of the global one?
>
> Yes, from Kent R. Dybvigs book "The Scheme Programming Language"
> (http://www.scheme.com/tspl2ed.html):
>
> (use-modules (ice-9 syncase))
>
> (define-syntax include
[...]
There's of course an important detail about the semantics:
If the macro `include' is expanded only once, as in Guile, the file
will be loaded only once. So, if you have a function using `include',
it will load the file on the first call, but not on subsequent.
You can compare `include' to "#include" in C.
There are ways to do it dynamically, but I won't talk about them since
the facilities for doing this might be removed from Guile fairly soon.