From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: Modules Date: Sat, 29 Jan 2011 13:18:16 +0000 Message-ID: <87y663df1j.fsf@ossau.uklinux.net> References: <20101208124502.5f25b64d@halmanfloyd> <20110129131315.506f1e8c@halmanfloyd> <8739obeu2a.fsf@ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1296307115 2476 80.91.229.12 (29 Jan 2011 13:18:35 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 29 Jan 2011 13:18:35 +0000 (UTC) Cc: Andy Wingo , guile-user@gnu.org To: Marek Kubica Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jan 29 14:18:30 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PjAh7-0002N0-AV for guile-user@m.gmane.org; Sat, 29 Jan 2011 14:18:25 +0100 Original-Received: from localhost ([127.0.0.1]:42763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjAh6-0005tc-Qt for guile-user@m.gmane.org; Sat, 29 Jan 2011 08:18:24 -0500 Original-Received: from [140.186.70.92] (port=41056 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjAh2-0005tR-JU for guile-user@gnu.org; Sat, 29 Jan 2011 08:18:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PjAh1-0003cw-6N for guile-user@gnu.org; Sat, 29 Jan 2011 08:18:20 -0500 Original-Received: from mail3.uklinux.net ([80.84.72.33]:42102) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PjAh1-0003cX-00 for guile-user@gnu.org; Sat, 29 Jan 2011 08:18:19 -0500 Original-Received: from arudy (unknown [78.145.31.137]) by mail3.uklinux.net (Postfix) with ESMTP id 6BB5C1F6722; Sat, 29 Jan 2011 13:18:17 +0000 (GMT) Original-Received: from neil-laptop (unknown [192.168.11.3]) by arudy (Postfix) with ESMTP id 011A13801E; Sat, 29 Jan 2011 13:18:16 +0000 (GMT) In-Reply-To: <8739obeu2a.fsf@ossau.uklinux.net> (Neil Jerram's message of "Sat, 29 Jan 2011 13:08:29 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 80.84.72.33 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8396 Archived-At: Neil Jerram writes: > Marek Kubica 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.