unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Neil Jerram <neil@ossau.homelinux.net>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: add-relative-load-path ?
Date: Mon, 23 Jan 2012 20:19:04 +0000	[thread overview]
Message-ID: <87aa5erx3b.fsf@neil-laptop.ossau.uklinux.net> (raw)
In-Reply-To: <87y5sypvre.fsf@pobox.com> (Andy Wingo's message of "Mon, 23 Jan 2012 11:18:29 +0100")

Andy Wingo <wingo@pobox.com> writes:

> Hi Neil,
>
> Thanks for the feedback!
>
> On Sun 22 Jan 2012 00:17, Neil Jerram <neil@ossau.homelinux.net> 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.

Thanks.

>> 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")))

Well it seems it has to be

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

because cond-expand errors if no clause is satisfied.

>   (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).

But yes, indeed that is nicer, and it obviously generalises to other
compatibility issues too.  Thanks for the idea!

Regards,
        Neil



  parent reply	other threads:[~2012-01-23 20:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-08 15:14 add-relative-load-path ? Andy Wingo
2012-01-14 21:48 ` Neil Jerram
2012-01-20 23:14   ` Andy Wingo
2012-01-21 23:17     ` Neil Jerram
2012-01-23 10:18       ` Andy Wingo
2012-01-23 15:45         ` Ludovic Courtès
2012-01-23 16:20           ` Andy Wingo
2012-01-23 19:36             ` Neil Jerram
2012-01-25 12:42             ` Ludovic Courtès
2012-01-25 14:31               ` Andy Wingo
2012-01-25 20:41                 ` Ludovic Courtès
2012-01-25 23:08                   ` Andy Wingo
2012-01-23 20:19         ` Neil Jerram [this message]
2012-01-30 20:20 ` add-relative-load-path ? - scm_add_load_path too? Ian Hulin
2012-01-31  8:53   ` Mark H Weaver
2012-01-31 16:10     ` Mark H Weaver
2012-02-01 23:30       ` Ian Hulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87aa5erx3b.fsf@neil-laptop.ossau.uklinux.net \
    --to=neil@ossau.homelinux.net \
    --cc=guile-devel@gnu.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).