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]

Loading files that load files? Questions and proposal.


In my current Guile-based project, I stick a number of important scheme
functions in a file called ctl.scm, which is needed by user programs and is
automatically loaded by my C program.  My problem is that I want to break
ctl.scm up into multiple files for easier maintainability, and have this
change be transparent so that programs depending upon ctl.scm don't need to
be modified.

Ideally, to split off some functions from ctl.scm, I would create a new
file, say ctl-utils.scm, put my functions into it, and stick a (load
"ctl-utils.scm") into ctl.scm.  However, this doesn't work.  The reason is
that my program might be running in a different directory, and will load
ctl.scm with gh_load("<path>/ctl.scm"), but the (load "ctl-utils.scm")
doesn't look in the <path> directory.  I also don't want write (load
"<path>/ctl-utils.scm"), since <path> will change each time the software is
installed on a new machine.

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.

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

Cordially,
Steven G. Johnson