This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: import path vs CLASSPATH


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]