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]

Question about proper use of `~/.guile' and `use-modules'


Unfortunately, neither `~/.guile', nor the concept of an init file, is
documented at all; and `use-modules' is documented only sketchily.

Here's some background:

I often use functions from `slib', and so a long time ago I created a
file named `~/.guile', which contained

     (use-modules (ice-9 slib))

(I also put a symbolic link named `slib', pointing to `/usr/lib/slib',
in the `share/guile/1.3.1' directory).

That allowed me to put (at the top of a scheme file), for example

     (require 'pretty-print)

and the appropriate slib code would get loaded.

However, sometime recently I noticed that this was no longer working.
That is, I would find that `require' wasn't defined.  I tried to
`debug' the problem, and changed my `~/.guile' to this:

    (use-modules (ice-9 slib))
    (display (string-append "`require' "
			    (if (defined? 'require)
				"is indeed"
			      "alas is not")
			    " defined\n"))

When I then restarted guile, I was surprised to see a message telling
me that `require' was indeed defined.

So it's as if the `use-modules' has effect only in the file in which
it appears.  I found that I could `work around' this by simply putting
the `use-modules' at the tops of my files that actually call
`require'.  It dawned on me that this might not be a bug at all, and
that perhaps forcing my files to explicitly load the slib module was a
Good Thing.  (However, I assume it makes my files unportable, since as
far as I know only guile defines `use-modules'.)

So, finally, here are my questions:

* Should I be using `~/.guile' as a startup file in the first place?

* If not, is there some other way I can have guile evaluate startup
  code?

* Am I right in guessing that `use-modules' is intended to affect only
  the file in which the call appears?

* If not, is this a bug?

I'd write the documentation that pertains to these issues myself, if I
understood them :(