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] |
If I got your message right the guile loader alreday works the way you describe. I've used this since I switched from using scm to using guile in all my work more than one year ago. This function is, however, not quite there in the way you want in the primitive-load, but on the other hand I'm not it should either. What you do is to set the variable %load-path to include what you want. These can be directory relative also if you prefer. Then I have one very simple primitive scm-require which I put in all files which need a specific scm file to be loaded so they will only be loaded the first time, when the corresponding property is not in the list scm-features. I've called it scm-require to not mix it up with the slib defined require, like: (scm-require 'files) (scm-require 'sets) (scm-require 'matrix) The corresponding property is set when the file is loaded. To extend or modify the load path I have a function extend-load-path which may look like: (extend-load-path "../scmlib" 'first) ;; alt: 'last 'remove (extend-load-path "./" 'first) I also did a slight modification of the load function, but now I don't remember if that was really necessary. It was in scm, but the guile load function automatically uses the %load-path. The modification was to check for the (scheme-file-suffix) in the first place, at each directory in the order given by %load-path. If you are interrested I can send you my library hacks. > 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? Best regards Roland Orre