This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Loading files that load files? Questions and proposal.


"Steven G. Johnson" <stevenj@alum.mit.edu> writes:

> My proposal: modify scm_primitive_load so that it keeps track of the
> current directory it is "in", and loads files relative to that path.  This
> seems like a reasonable change to me--I don't see how it could break
> anyone's code, and it seems to me that it will make the load function
> considerably more useful.  I am willing to make these changes in the Guile
> source code; it doesn't look like it will be too hard.  However, I wanted
> to get feedback first to see if people think this is a good idea.

To me this sounds like a good idea, but I'd also like to hear what
others have to say on this.

> Is there a better way to accomplish what I want?  How do people normally
> write libraries in Scheme?

There is a load path specified by the variable `%load-path'.  It
either contains a standard path derived from the "prefix" path during
Guile configuration, or a path defined through the environment
variable GUILE_LOAD_PATH.

When you define a guile module you specify which other modules are
needed:

  (define-module (my-package my-module)
    :use-module (used-package-1 used-module-1)
    :use-module (used-package-1 used-module-2))

Those modules are searched for in the %load-path.  For example,
(used-package-1 used-module-1) is expected to be found at
<path>/used-package-1/used-module-1.scm where <path> is one of the
paths on the %load-path.

/mdj