From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18365 invoked by alias); 8 Feb 2017 21:42:41 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 18305 invoked by uid 89); 8 Feb 2017 21:42:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=locates, Per, Lane, Hx-languages-length:1830 X-HELO: aibo.runbox.com Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Feb 2017 21:42:25 +0000 Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1cba0L-0002ME-4x; Wed, 08 Feb 2017 22:42:21 +0100 Received: from 70-36-239-8.dsl.dynamic.fusionbroadband.com ([70.36.239.8] helo=localhost.localdomain) by mailfront11.runbox.com with esmtpsa (uid:757155 ) (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1cbZzs-0005nc-1X; Wed, 08 Feb 2017 22:41:52 +0100 Subject: Re: import path vs CLASSPATH To: Peter Lane , kawa@sourceware.org References: <4f61b6b2-78f7-a327-6eb3-7778eab00233@peterlane.info> From: Per Bothner Message-ID: Date: Wed, 08 Feb 2017 21:42:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <4f61b6b2-78f7-a327-6eb3-7778eab00233@peterlane.info> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2017-q1/txt/msg00050.txt.bz2 On 02/08/2017 10:36 AM, Peter Lane wrote: > (This is not really a question, but more an observation - perhaps a curious query.) > > I found there's a difference between import path and CLASSPATH, with respect to how kawa locates libraries: "import path" seems to be relative to the input program, whereas CLASSPATH is relative to the caller. > > The Kawa documentation says "The default search path is |"."| - i.e. just search relative to the current root"; I was expecting the current root to be the directory where I ran kawa, but it appears to be the location of the program. Depends what you mean by "the program". The path is relative to the *importing* module. I.e. the source file that contains the import or require form. The manual does say: For example the source to a library with the name (x y) that compiles to a class x.y might be a file named /a/b/x/y.scm. Then the current root would be /a/b/ - that is the directory that results from removing the library name suffix from the file name. More generally: assume the current module has N name components. For example the name (x y) (with the class name x.y) has 2 components. The current root is what you get when you take the current file name (say "/a/b/c/d.scm"), and remove everything after the N’th slash ("/") from the end (say "c/d.scm"; what remains (e.g. "/a/b/" is the current root. (If the current input source is not a named file, use the value of (current-path) with a "/" appended.) This is how include files work in C, for example. Perhaps changing "If the resulting filename is relative, then it is resolved relative to the current root." adding ", which is derived from the name of the source file containing the import/require" might make it clearer? -- --Per Bothner per@bothner.com http://per.bothner.com/