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:08:29 +0000 Message-ID: <8739obeu2a.fsf@ossau.uklinux.net> References: <20101208124502.5f25b64d@halmanfloyd> <20110129131315.506f1e8c@halmanfloyd> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1296306576 32551 80.91.229.12 (29 Jan 2011 13:09:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 29 Jan 2011 13:09:36 +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:09:32 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 1PjAYO-00078E-VF for guile-user@m.gmane.org; Sat, 29 Jan 2011 14:09:25 +0100 Original-Received: from localhost ([127.0.0.1]:39886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjAYN-0003Ef-Ip for guile-user@m.gmane.org; Sat, 29 Jan 2011 08:09:23 -0500 Original-Received: from [140.186.70.92] (port=49998 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjAYB-0003Ea-G2 for guile-user@gnu.org; Sat, 29 Jan 2011 08:09:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PjAYA-0001tp-2c for guile-user@gnu.org; Sat, 29 Jan 2011 08:09:11 -0500 Original-Received: from mail3.uklinux.net ([80.84.72.33]:42061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PjAY9-0001lc-Pr for guile-user@gnu.org; Sat, 29 Jan 2011 08:09:10 -0500 Original-Received: from arudy (unknown [78.145.31.137]) by mail3.uklinux.net (Postfix) with ESMTP id 657C21F6722; Sat, 29 Jan 2011 13:08:30 +0000 (GMT) Original-Received: from neil-laptop (unknown [192.168.11.3]) by arudy (Postfix) with ESMTP id D68B33801E; Sat, 29 Jan 2011 13:08:29 +0000 (GMT) In-Reply-To: <20110129131315.506f1e8c@halmanfloyd> (Marek Kubica's message of "Sat, 29 Jan 2011 13:13:15 +0100") 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:8395 Archived-At: 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) (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))))) (else (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))))) This has the effect of adding the parent of the script-containing directory to the load path. Part of the complexity is supporting both 1.8 and 1.9/2.0. For 1.9/2.0 support only, I believe it could be simplified by changing `load' to `include', and retaining only the body of the `eval-when'. Regards, Neil