unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: Joel James Adamson <adamsonj@email.unc.edu>
Cc: guile-user@gnu.org
Subject: Re: Loading a module from the current-working-directory
Date: Thu, 22 Jul 2010 09:52:45 +0200	[thread overview]
Message-ID: <87eiewymuq.fsf@ambire.localdomain> (raw)
In-Reply-To: <m3bpa060mt.fsf@chondestes.bio.unc.edu> (Joel James Adamson's message of "Wed, 21 Jul 2010 16:27:54 -0400")

() Joel James Adamson <adamsonj@email.unc.edu>
() 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	other threads:[~2010-07-22  7:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-21 20:27 Loading a module from the current-working-directory Joel James Adamson
2010-07-22  7:52 ` Thien-Thi Nguyen [this message]
2010-07-22 16:51   ` Joel James Adamson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eiewymuq.fsf@ambire.localdomain \
    --to=ttn@gnuvola.org \
    --cc=adamsonj@email.unc.edu \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).