Exporting a nonexistent variable

Tommi Höynälänmaa <[email protected]>
Newsgroups gmane.lisp.guile.devel
Message-ID <[email protected]>
Exporting a nonexistent variable in a guile module can cause runtime 
errors. To see this, consider the following example:

--- mod1.scm ---

(define-module (mod1))

(export myproc)

(define (myproc)
   (display "Hello\n"))

--- end ---

--- mod2.scm ---
(define-module (mod2))

(export myproc
         myproc2)

(define (myproc2)
   (display "Hello again\n"))

--- end ---

--- program.scm ---
(use-modules (mod1)
              (mod2))

(define (main args)
   (myproc))

--- end ---

Running "guile -e main -s program.scm" causes the following error

---

WARNING: (guile-user): `myproc' imported from both (mod1) and (mod2)
Backtrace:
In ice-9/boot-9.scm:
   1762:12  4 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
            3 (apply-smob/0 #<thunk 7f3e3cd10300>)
In ice-9/boot-9.scm:
     731:2  2 (call-with-prompt ("prompt") #<procedure 7f3e3cd22b00 …> …)
In ice-9/eval.scm:
     619:8  1 (_ #(#(#<directory (guile-user) 7f3e3cd13c80>)))
In program.scm:
       6:3  0 (main _)

program.scm:6:3: In procedure main:
Unbound variable: myproc

---

I think Guile could report a warning if a nonexistent variable is 
exported as the cause of this kind of errors may be difficult to find in 
a large program.

      - Tommi Höynälänmaa

-- 
Kotisivu / Homepage: http://www.iki.fi/tohoyn/
Sähköposti / E-Mail: [email protected]
GPG-sormenjälki / GPG fingerprint:
55F4 2477 7155 3528 5CB2 2B7A BB86 1FDE 4046 0F83
FT, Debian-ylläpitäjä / PhD, Debian Maintainer
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.