IRC channel logs


back to list of logs

<rlb>So is there a normal way to avoid the undefined variable warning if you use say foo in a scheme module and foo is being defined by a shared lib that it loads?
<rlb>In 2.2 you could just (define foo #f) (load-lib) and then use foo, to silence the warning, but in 3.0, foo stays #f.
<mwette>rlb: maybe (define foo (make-parameter #f)) and have load lib do (foo <value>)
<mwette>Then of course you need to reference using (foo) all the time.
<mwette>but not sure that works either, because any new thread will start with foo as #f
<mwette>rlb: Do you have "#:declarative? #f" in your define-module form?
<mwette>I think the "#:declarative? #f" is what you want. Look at section 6.20.9 in the Guile 3.0.0 manual
<rlb>mwette: thanks, though that doesn't appear to affect the warnings. I assume the warnings might be because the shared lib isn't being loaded at compile time, so guile doesn't know about the definitions the shared library is going to establish at runtime. So I did try putting the load-extension inside a suitable eval-when, which did in fact fix the warnings for one shared lib, and caused the other to crash. That's when I thought I
<rlb>should ask what the preferred way is to handle this case before any further guessing.
<mwette>The compiler just assumes foo is always #f and so expands references to foo in your code as `#f'.
<mwette>rlb: just try adding "#:declarative? #f" in (define-module ...)
<rlb>I did -- no effect.
<rlb>I still see all the undefined warnings.
<rlb>(unless I did i wrong -- I'll try again later)
<rlb>Oh, wait.
*rlb may have done the opposite of what he intended...
<mwette>rlb: it says you can also reload the module after (load-lib)