* Loading a module from the current-working-directory
@ 2010-07-21 20:27 Joel James Adamson
2010-07-22 7:52 ` Thien-Thi Nguyen
0 siblings, 1 reply; 3+ messages in thread
From: Joel James Adamson @ 2010-07-21 20:27 UTC (permalink / raw)
To: guile-user
[-- Attachment #1: Type: text/plain, Size: 2166 bytes --]
Hello,
I've written a simple module:
(define-module (popgen popgen))
(export popgen)
(use-modules (ice-9 format))
(define *numprec* "~10,8,,,0f ")
(define *numformat* (string-append "~{" *numprec* "~}~%"))
(define (popgen popfun data)
;; POPFUN is a function that evaluates the vector DATA to yield the
;; next generation's data; print the data to the terminal and then
;; check the result of evaluating (popfun data); if the new vector
;; is close enough to the old one, exit and return #f; otherwise
;; call (popgen POPFUN (POPFUN DATA))
;;
;; First print the data to the current-output-port (user routines
;; may want to modify this to send the data down a pipe)
(format #t "~{~}~%" num-format (vector->list data))
(let* ((new (popfun data))
(diff (eudiff (new data))))
(cond ((< diff 1e-15) #f)
(else (popgen popfun new)))))
(define (eudiff vec1 vec2)
(sqrt (apply
+
(map (lambda (x y)
(* (- x y) (- x y)))
(vector->list vec1)
(vector->list vec2)))))
I'd like to test its features at the REPL, but I am having serious
trouble loading it. I'm not sure if the problem is in the definition or
how I'm loading it.
I get the following behavior:
guile> %load-path
("/usr/share/guile/site" "/usr/share/guile/1.8" "/usr/share/guile")
guile> (set! %load-path (cons (getcwd) %load-path))
guile> %load-path
("/home/joel/Documents/ss_theory/scm" "/usr/share/guile/site" "/usr/share/guile/1.8" "/usr/share/guile")
guile> (use-modules (popgen popgen))
Backtrace:
In standard input:
76: 0* (use-modules (popgen popgen))
76: 1 (eval-case (# # *unspecified*) (else #))
76: 2 (begin (process-use-modules (list (list #))) *unspecified*)
In unknown file:
?: 3* [process-use-modules (((popgen popgen)))]
<unnamed port>: In procedure process-use-modules in expression (process-use-modules (list #)):
<unnamed port>: no code for module (popgen popgen)
ABORT: (misc-error)
Where am I going wrong?
Thanks,
Joel
--
Joel J. Adamson
Servedio Lab
University of North Carolina at Chapel Hill
FSF Member #8164
http://www.unc.edu/~adamsonj
[-- Attachment #2: Type: application/pgp-signature, Size: 229 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Loading a module from the current-working-directory
2010-07-21 20:27 Loading a module from the current-working-directory Joel James Adamson
@ 2010-07-22 7:52 ` Thien-Thi Nguyen
2010-07-22 16:51 ` Joel James Adamson
0 siblings, 1 reply; 3+ messages in thread
From: Thien-Thi Nguyen @ 2010-07-22 7:52 UTC (permalink / raw)
To: Joel James Adamson; +Cc: guile-user
() 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Loading a module from the current-working-directory
2010-07-22 7:52 ` Thien-Thi Nguyen
@ 2010-07-22 16:51 ` Joel James Adamson
0 siblings, 0 replies; 3+ messages in thread
From: Joel James Adamson @ 2010-07-22 16:51 UTC (permalink / raw)
To: Thien-Thi Nguyen; +Cc: guile-user
[-- Attachment #1: Type: text/plain, Size: 1219 bytes --]
Thien-Thi Nguyen <ttn@gnuvola.org> writes:
> () 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
Thanks, I have updated my filesystem hierarchy to reflect the module
hierarchy.
Joel
--
Joel J. Adamson
Servedio Lab
University of North Carolina at Chapel Hill
FSF Member #8164
http://www.unc.edu/~adamsonj
[-- Attachment #2: Type: application/pgp-signature, Size: 229 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-22 16:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-21 20:27 Loading a module from the current-working-directory Joel James Adamson
2010-07-22 7:52 ` Thien-Thi Nguyen
2010-07-22 16:51 ` Joel James Adamson
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).