guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: add-relative-load-path ?


From: Andy Wingo
Subject: Re: add-relative-load-path ?
Date: Mon, 23 Jan 2012 11:18:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Hi Neil,

Thanks for the feedback!

On Sun 22 Jan 2012 00:17, Neil Jerram <address@hidden> writes:

> Thing 1 is that (current-filename) can return a relative filename, or a
> filename with a "./" in its middle
[...]
>
> Would there be any downside from putting [canonicalize-path] inside
> current-filename, so that current-filename always returns a canonical
> file name?

No, and I think that is the right thing to do in this case, because it
avoids embedding assumptions about the current working directory into
compiled .go files.  I have made this change.

> Thing 2 is that it remains slightly inelegant to cater for both 1.8 and
> 2.0.  I think the minimal complete solution is to write
>
> (cond-expand (guile-2 (include "setup-load-path.scm"))
>              (else (load "setup-load-path.scm")))
>
> at top level in every uninstalled script, and then something like
>
> (cond-expand (guile-2
>             (add-to-load-path
>              (dirname
>               (dirname
>                (canonicalize-path (current-filename))))))
>            (else
>               ;; Less elegant code for 1.8...
>             (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)))))
>
> in setup-load-path.scm.
>
> But without a time machine I don't think anything can be done to make
> either of those fragments more concise.

Well, you could instead do:

  (cond-expand ((not guile-2) (load "guile-2.0-compat.scm")))

  (add-to-load-path (dirname (dirname (current-filename))))

Then in guile-2.0-compat.scm you have shims to make guile 1.8 offer a
2.0 interface (in this case, current-filename and add-to-load-path).

>> address@hidden, and @code{load-path} and
>
> Is it 'load-path' or 'load-from-path'?

load-from-path.  Fixed!

Thanks,

Andy
-- 
http://wingolog.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]