[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Exporting a nonexistent variable
From: |
Attila Lendvai |
Subject: |
Re: Exporting a nonexistent variable |
Date: |
Wed, 13 Nov 2024 22:22:58 +0000 |
> 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.
you are exporting _symbols_ (unique identities) from modules, not variables (or
bindings).
there are various use-cases where one wants to export a symbol from a module
without binding any value to it in the module where it is being exported from.
> WARNING: (guile-user): `myproc' imported from both (mod1) and (mod2)
this^ is key, never ignore such warnings! i'd go as far as to suggest that this
warning should be turned into an error. that would force the author to fix his
package definitions to explicitly resolve such collisions.
sidenote: any serious codebase should compile with zero warnings, otherwise
people start to ignore such warnings, they accummulate, and then waste precious
programmer attention in debugging sessions.
our (Common Lisp) team used to have a running joke that if a situation just
doesn't make any sense, then it must be a package (module) issue: `foo` and
`foo` may print the same, but can be different identities.
> 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
there are two `myproc` symbols at play here, and you're trying to dereference
the one that has no value bound to. you've been warned prior to this.
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
You cannot wake up someone who is only pretending to be asleep.
— Indian proverb