Neil Jerram <n...@ossau.uklinux.net> writes: > Marek Kubica <ma...@xivilization.net> writes: > >> What about "the same directory that the file is in"? The point is, when >> writing scripts that become larger than one file, splitting them into >> modules becomes immensely painful because the modules cannot find each >> other. > > I agree that this is a bit awkward. My current solution is > > (load "setup-load-path.scm") > > at the start of each top-level script - which relies on the fact that > `load' will look in the same directory as the script file - with > setup-load-path.scm containing: > > (cond-expand (guile-2 > (eval-when (load compile)
It's amazing how writing an email sets you thinking about whether something is really correct... In fact I think the top level probably needs to be (cond-expand (guile-2 (include "setup-load-path.scm")) (else (load "setup-load-path.scm"))) so that the path is set up for 1.9/2.0 compilation time. I wonder if it works to write that as ((cond-expand (guile-2 include) (else load)) "setup-load-path.scm") And then setup-load-path.scm can be just (let* ((bindir (dirname (car (command-line)))) (absdir (cond ((string=? bindir ".") (getcwd)) ((string-match "^/" bindir) bindir) (else (in-vicinity (getcwd) bindir))))) (set! %load-path (cons (in-vicinity absdir "..") %load-path))) Which isn't so bad.