From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.devel Subject: Re: add-relative-load-path ? Date: Mon, 23 Jan 2012 20:19:04 +0000 Message-ID: <87aa5erx3b.fsf@neil-laptop.ossau.uklinux.net> References: <87zkdycjl6.fsf@pobox.com> <87boq6q7jq.fsf@neil-laptop.ossau.uklinux.net> <87zkdiq851.fsf@pobox.com> <87r4yssl1p.fsf@neil-laptop.ossau.uklinux.net> <87y5sypvre.fsf@pobox.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1327349960 6479 80.91.229.12 (23 Jan 2012 20:19:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 23 Jan 2012 20:19:20 +0000 (UTC) Cc: guile-devel To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jan 23 21:19:16 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RpQMD-0002Ur-FT for guile-devel@m.gmane.org; Mon, 23 Jan 2012 21:19:13 +0100 Original-Received: from localhost ([::1]:55266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpQMC-00008V-QO for guile-devel@m.gmane.org; Mon, 23 Jan 2012 15:19:12 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:35714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpQM9-000089-8C for guile-devel@gnu.org; Mon, 23 Jan 2012 15:19:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RpQM7-0001xP-Qe for guile-devel@gnu.org; Mon, 23 Jan 2012 15:19:09 -0500 Original-Received: from out1.ip06ir2.opaltelecom.net ([62.24.128.242]:38683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpQM7-0001xK-Jw for guile-devel@gnu.org; Mon, 23 Jan 2012 15:19:07 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAGDAHU9OkRvB/2dsb2JhbABCrimBBoFyAQEEATocIwULCAMhJQ8BBCUkExuHYQK4P4wmBKdn X-IronPort-AV: E=Sophos;i="4.71,557,1320624000"; d="scan'208";a="525131581" Original-Received: from host-78-145-27-193.as13285.net (HELO arudy) ([78.145.27.193]) by out1.ip06ir2.opaltelecom.net with ESMTP; 23 Jan 2012 20:19:05 +0000 Original-Received: from neil-laptop.ossau.uklinux.net.ossau.homelinux.net (host-78-145-27-193.as13285.net [78.145.27.193]) by arudy (Postfix) with ESMTPA id 9171C3802E; Mon, 23 Jan 2012 20:19:04 +0000 (GMT) In-Reply-To: <87y5sypvre.fsf@pobox.com> (Andy Wingo's message of "Mon, 23 Jan 2012 11:18:29 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 62.24.128.242 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13649 Archived-At: Andy Wingo writes: > Hi Neil, > > Thanks for the feedback! > > On Sun 22 Jan 2012 00:17, Neil Jerram 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