Effect of include-library-declarations on "current root" for import

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Effect of include-library-declarations on "current root" for import

Sudarshan S Chawathe
This question is about "current root" as used in the "searching for
source files" section of the manual (within "importing from a library").

The main question is: Is the "current root" for library imports spliced
in using include-library-declarations (potentially) different from the
"current root" of the file containing the include-library-declarations?

My understanding of the description in the manual, and the recent thread
on this mailing list ("import path vs CLASSPATH") is that when a library
definition in a file alpha.sld uses

  (include-library-declarations "../foo/bar/common.scm")

to splice in some forms, the current root for any imports in common.scm
is the same as the current root for alpha.sld, regardless of the
location of common.scm.

However, that does not appear to be true, based on the small example
included below.  (If I move common.scm to the "ab" directory and change
"../common.scm" to "common.scm" then there are no errors.)

I am not sure if this is intended/desirable behavior.

Regards,

-chaw


Example...

$ cat test-ab.scm
(import (scheme base)
        (scheme write)
        (alpha))
(write "test-ab")
(write alpha)
(newline)

$ cat alpha.sld
(define-library (alpha)
  (export alpha)
  (import (scheme base)
          (scheme write))
  (include-library-declarations "../common.scm")
  (begin
    (write "alpha, bravo: ")
    (write bravo)
    (newline)
    (define alpha bravo)))

$ cat ../common.scm
(import (bravo))

$ cat bravo.sld
(define-library (bravo)
  (export bravo)
  (import (scheme base)
          (scheme write))
  (begin
    (write "bravo")
    (newline)
    (define bravo 6)))

$ kawa -Dkawa.import.path="./*.sld" test-ab.scm
/home/chaw/res/scheme/kawa/misc/ab/../common.scm:1:9: unknown library (bravo)
/home/chaw/res/scheme/kawa/misc/ab/alpha.sld:8:12: warning - no declaration seen for bravo
/home/chaw/res/scheme/kawa/misc/ab/alpha.sld:10:19: warning - no declaration seen for bravo

$ kawa --version
Kawa 2.3.1 (git describe: kawa-2.3-4-gcb36c64-dirty)
Copyright (C) 2017 Per Bothner

$ uname -a
Linux vereq.eip10.org 3.16.0-4-686-pae #1 SMP Debian 3.16.39-1+deb8u1 (2017-02-22) i686 GNU/Linux
$

Reply | Threaded
Open this post in threaded view
|

Re: Effect of include-library-declarations on "current root" for import

Per Bothner
On 03/01/2017 01:52 PM, Sudarshan S Chawathe wrote:

> This question is about "current root" as used in the "searching for
> source files" section of the manual (within "importing from a library").
>
> The main question is: Is the "current root" for library imports spliced
> in using include-library-declarations (potentially) different from the
> "current root" of the file containing the include-library-declarations?
>
> My understanding of the description in the manual, and the recent thread
> on this mailing list ("import path vs CLASSPATH") is that when a library
> definition in a file alpha.sld uses
>
>   (include-library-declarations "../foo/bar/common.scm")
>
> to splice in some forms, the current root for any imports in common.scm
> is the same as the current root for alpha.sld, regardless of the
> location of common.scm.
I think it has to be. The "current file name" could plausibly be either
the included files or the including file.  However, "current root" is defined
in terms of the components of the library name, so it should be relative
to the library source file.

Could you try the attached patch?
--
        --Per Bothner
[hidden email]   http://per.bothner.com/

import.patch (603 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Effect of include-library-declarations on "current root" for import

Sudarshan S Chawathe
> Could you try the attached patch?

It works as expected with the patch. Thanks!

-chaw