unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Modules with Circular Dependencies
@ 2011-03-18 18:15 Noah Lavine
  2011-03-18 20:45 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Noah Lavine @ 2011-03-18 18:15 UTC (permalink / raw)
  To: guile-devel

Hello all,

I recently ran up against an issue about modules with circular
dependencies while working on PEG stuff. I reduced it to the following
test case.

Here is file "test-a.scm":

(define-module (test-a)
  #:use-module (test-b))

(define-syntax hello
  (syntax-rules ()
    ((hello) "Hello, world!\n")))

And here is "test-b.scm":

(define-module (test-b)
  #:use-module (test-a))

(display (hello))

As you can see, test-a and test-b have a circular dependency in which
test-a defines syntax that test-b uses.

If I run "guile -L "." -s test-a.scm", I get the error

;;; WARNING: compilation of /Users/noah/Desktop/guile/guile/test-a.scm failed:
;;; key unbound-variable, throw_args ("module-lookup" "Unbound
variable: ~S" (hello) #f)

Clearly the order of compilation is a problem. So I tried this
modified test-a.scm:

(define-module (test-a))

(define-syntax hello
  (syntax-rules ()
    ((hello) "Hello, world!\n")))

(use-modules (test-b))

I moved the reference to test-b to the end, but got the same error.

So clearly the module system doesn't like circular dependencies on
syntax. I think it probably should understand them. I have a feeling
that they don't end up adding complexity to compilation, even though
it seems like they would, because in order to compile a module you
have to search its dependencies for syntax definitions anyway.
However, either way, I don't think this issue is documented in the
manual.

So what do you all think should happen in this case?

Noah



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-03-24 21:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-18 18:15 Modules with Circular Dependencies Noah Lavine
2011-03-18 20:45 ` Ludovic Courtès
2011-03-18 21:16   ` Noah Lavine
2011-03-24 21:50     ` Andy Wingo

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).