guile-user
[Top][All Lists]
Advanced

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

Re: Loading a module from the current-working-directory


From: Thien-Thi Nguyen
Subject: Re: Loading a module from the current-working-directory
Date: Thu, 22 Jul 2010 09:52:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

() Joel James Adamson <address@hidden>
() Wed, 21 Jul 2010 16:27:54 -0400

   (define-module (popgen popgen))

   [...]

   guile> (set! %load-path (cons (getcwd) %load-path))
   guile> (use-modules (popgen popgen))

   [...]
   <unnamed port>: no code for module (popgen popgen)
   ABORT: (misc-error)

   Where am I going wrong?

For module name ‘(a b c)’, guile constructs relative filenames:

 a/b/c.scm  (S: scheme)
 a/b/c      (R: raw)

and searches for the file DIR/S and DIR/R for each DIR in ‘%load-path’
(see variable ‘%load-extensions’).  In this case,

 (a b  ) ≘ (popgen       )        ; module name prefix
      c  ≘         popgen         ; module name leaf

The error you see means that none of these files can be found:

 /home/joel/Documents/ss_theory/scm/popgen/popgen.scm
 /home/joel/Documents/ss_theory/scm/popgen/popgen
 /usr/share/guile/site/popgen/popgen.scm
 /usr/share/guile/site/popgen/popgen
 /usr/share/guile/1.8/popgen/popgen.scm
 /usr/share/guile/1.8/popgen/popgen
 /usr/share/guile/popgen/popgen.scm
 /usr/share/guile/popgen/popgen

Absent a way to associate a module name to a filesystem directory
in ‘%load-path’ in Scheme (e.g., module catalogs in Guile 1.4.x),
a common workaround is to implement an alias in the filesystem:

 ln -s /home/joel/Documents/ss_theory/scm popgen

This approach works here because the module name prefix has length 1.
Another way is to avoid having a prefix in the module name, but that's
probably not a good idea if the module is intended for installation.
Yet another way is to call ‘primitive-load’ prior to ‘use-modules’,
but that's somewhat ugly.

thi



reply via email to

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