[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set-current-module in .guile ?

From: Neil Jerram
Subject: Re: set-current-module in .guile ?
Date: Wed, 09 Apr 2008 21:16:43 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

"Scott N. Walck" <address@hidden> writes:

> Dear Guilers,
> Dan Gildea has ported a large fraction of Gerry Sussman's scmutils
> code from MIT-scheme to guile.

That sounds interesting!

>  In doing so, he uses guile modules
> instead of MIT-scheme environments.  Much of the code creates a module
> called "generic-environment".  In an interactive guile session, you
> type
> (set-current-module generic-environment)
> and this redefines "+", for example, to add functions and vectors.
> I would like to know if there is a way to set the interactive
> environment to "generic-environment" in a .guile file.  If I put
> (set-current-module generic-environment)
> in a .guile file, it does nothing.  (I suppose because the current
> module when reading the .guile file is different from the current
> module in an interactive guile session?)

Some further thoughts on this...  When you invoke Guile interactively,
what it actually does is run a canned script, namely:

  (load-user-init)         ; This loads your .guile

All of those procedures are defined in ice-9/boot-9.scm, so you can
see what they do by looking at their code.

The cause of your specific problem is that (top-repl) does:

  (let ((guile-user-module (resolve-module '(guile-user))))
    (set-current-module guile-user-module)

So even though (set-current-module generic-environment) in .guile does
have an effect, that effect is overridden by the later
set-current-module call here.

One overall solution is to settle for (guile-user) being your current
module, and import everything you need from generic-environment by
making (guile-user) use generic-environment - as has been
suggested (and hopefully now debugged!) by others.

Another option is to take a copy of the (top-repl) code, and modify it
to do what you want - i.e. the set the current module to
generic-environment, instead of to (guile-user).  Then you can create
a file containing the definition of scmutils-top-repl, and top level


and invoke as "guile -s <filename>".

Hope that helps; let us know if you have further questions!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]