Hi,<br><br>I've just been badly bitten by some strange 'require' behavior that took me several hours to track down. I don't know if it's a feature or a bug, but just in case let me share it. And if anyone has an explanation, that'd be informative.<br>
<br>Long story short: <br><br>If you 'raco link my-dir' and sometimes (require my-dir/my-file) and other times (require "my-file.rkt"), you may get into trouble... if you run it via xinit (there may be other cases though).<br>
It looks like the two require forms makes my-file's "visibility" (or whatever the correct technical term is) differ.<br><br>Long story:<br><br>Say I have a module base.rkt exporting the parameter p with initial value "base".<br>
base.rkt:<br>#lang racket/base<br>(provide p)<br>(define p (make-parameter "base"))<br><br>Module a.rkt (in the same directory) require's base.rkt, changes p value to "a", and require's b.rkt.<br>
a.rkt:<br>#lang racket/base<br>(require "base.rkt" <br> "b.rkt")<br>(p "a")<br>(printf "p in a.rkt: ~a\n" (p))<br>(b-print-p)<br><br>The required module b.rkt just prints the value of parameter p.<br>
b.rkt:<br>#lang racket/base<br>(require "base.rkt")<br>(provide b-print-p)<br>(define (b-print-p)<br> (printf "p in b.rkt: ~a\n" (p)))<br><br><br>Then if you simply:<br>$ racket a.rkt<br>things go as I would expect, i.e., it prints:<br>
p in a.rkt: a<br>p in b.rkt: a<br> which is fine.<br><br>Now do the following:<br>- Let A be the directory which contains a.rkt, b.rkt, and base.rkt. Do:<br>$ raco link A <br>in A's parent directory.<br>- In file b.rkt (and only in b.rkt), change (require "base.rkt") to (require A/base)<br>
- write (and this is necessary apparently):<br>racket a.rkt <br>in you .xinitrc file (as the only line)<br><br>Now if on a login shell you type:<br>$ xinit -- :1<br>you should get:<br>p in a.rkt: a<br>p in b.rkt: base<br>
which does not look fine.<br><br>Notes:<br><br>If you try:<br>$ racket a.rkt<br>You have the correct "a\na" output.<br><br>Also, if you replace "base.rkt" by A/base in a.rkt, all is fine too.<br><br>
Laurent<br>