public inbox for
 help / color / mirror / Atom feed
From: Per Bothner <>
To: Peter Lane <>,
Subject: Re: import path vs CLASSPATH
Date: Wed, 08 Feb 2017 21:42:00 -0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

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

  reply	other threads:[~2017-02-08 21:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08 18:37 Peter Lane
2017-02-08 21:42 ` Per Bothner [this message]
2017-02-13 19:31   ` Peter Lane

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:

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

  git send-email \ \ \ \ \

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