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 modules [PROBLEM/SOLUTION]


Alex Stark writes:

 > [START SESSION]
 > 
 > guile> (use-modules (gmat gnuplot))
 > 
 > [ERROR]
 > 
 > guile> (set! %load-path (cons (string-append (getenv "HOME")
 > "/statproj") %load-path))
 > 
 > guile> %load-path
 > ("/home/stark/statproj" "/home/stark/scheming/zguile/share/guile/site"
 > "/home/stark/scheming/zguile/share/guile/1.3.1"
 > "/home/stark/scheming/zguile/share/guile" ".")
 > 
 > guile> (use-modules (gmat gnuplot))
 > 
 > [ERROR]

I also consider this a bug.  It is the result of `resolve-interface' in
ice-9/boot-9.scm assuming that if a module name is resolvable, its
interface is already resolved.  The two processes are not the same,
however, as the above usage shows, and so the assumption is incorrect.
Here is a `resolve-interface' that does not make that assumption:

(define (resolve-interface name)
  (let ((module (resolve-module name)))
    (and module
         (or (module-public-interface module)
             (begin
               (or (try-module-linked name)
                   (try-module-autoload name)
                   (try-module-dynamic-link name))
               (module-public-interface module))))))

Basically, we retry loading if the interface is not defined.  The
triple-or is snarfed from `resolve-module' and should probably be
factored:

(define (try-module name)
  (or (try-module-linked name)
      (try-module-autoload name)
      (try-module-dynamic-link name)))

Then it can be used in both `resolve-interface' and `resolve-module'.
Gee, I'm developing a liking for this module-madness.  Please just shoot
me now!

thi