unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Exporting a nonexistent variable
@ 2024-11-04 12:26 Tommi Höynälänmaa
  2024-11-04 20:43 ` Maxime Devos
  2024-11-13 22:22 ` Attila Lendvai
  0 siblings, 2 replies; 9+ messages in thread
From: Tommi Höynälänmaa @ 2024-11-04 12:26 UTC (permalink / raw)
  To: guile-devel

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: tommi.hoynalanmaa@iki.fi
GPG-sormenjälki / GPG fingerprint:
55F4 2477 7155 3528 5CB2 2B7A BB86 1FDE 4046 0F83
FT, Debian-ylläpitäjä / PhD, Debian Maintainer




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

end of thread, other threads:[~2024-11-14 10:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-04 12:26 Exporting a nonexistent variable Tommi Höynälänmaa
2024-11-04 20:43 ` Maxime Devos
2024-11-05  7:25   ` Tommi Höynälänmaa
2024-11-05  9:23     ` Maxime Devos
2024-11-05  9:26       ` Maxime Devos
2024-11-05 10:00       ` Tommi Höynälänmaa
2024-11-13 22:22 ` Attila Lendvai
2024-11-14  9:42   ` Maxime Devos via Developers list for Guile, the GNU extensibility library
2024-11-14 10:27     ` Mikael Djurfeldt

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