public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: spellcard199 <spellcard199@protonmail.com>
To: "J. Vincent Toups" <vincent.toups@gmail.com>
Cc: "kawa@sourceware.org" <kawa@sourceware.org>
Subject: Re: Behavior of (import ...) in R7RS define-library forms
Date: Sat, 06 Feb 2021 17:04:31 +0000	[thread overview]
Message-ID: <BJiQOnJGWAvYRvlZdzpt-1QAqLH8Z6GFXXQPawwSkRuIWpFlB1y1zdnjA6UU6797haKnL5VTERoddIP0iUzisEXkYY--VqJNpsjG5vyv6KE=@protonmail.com> (raw)
In-Reply-To: <CAE8gMz07hWQ7oq7257ULDg35pQ=mpoC7hBCvskytsSMo4uwK2Q@mail.gmail.com>

Hello. I'm far from being an expert (and not using Java nor Kawa atm)
but after trying to reproduce your project structure I think it's a
problem of how "kawa.import.path" is resolved.

2 things seem to work:

1) If you can, instead of -Dkawa.import.path="./src/*.scm" use an
absolute path (e.g.):
  -Dkawa.import.path="/home/user/development/project_name/src/*.scm"

2) If you must use a relative path:
   1. Use: -Dkawa.import.path="./*.scm"
   2. Start repl from inside the src directory

I just skimmed rapidly through it and I may be wrong but I think the
section "19.6.2 Searching for source files" in the Kawa manual expains
how this works.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday 5 February 2021 15:21, J. Vincent Toups via Kawa <kawa@sourceware.org> wrote:

> I have two r7rs-style libraries, one of which depends on the other,
> located in the following filesystem structure:
>
> src/lib/shadchen-helpers.scm
> src/lib/shadchen.scm
>
> In principle, shadchen-helpers isn't useful on its own - it provides
> some helper material for the shadchen library.
>
> The library definitions look like this:
>
> $ find src/ -iname "*.scm" | grep lib | xargs head -n 2
> ==> src/lib/shadchen-helpers.scm <==
> (define-library
> (lib shadchen-helpers)
>
> ==> src/lib/shadchen.scm <==
> (define-library
> (lib shadchen)
>
> So if I start a repl like this:
>
> $ java -jar lib/kawa.jar -Dkawa.import.path="./src/*.scm"
>
> Kawa can find the libraries if I do an import:
>
> #|kawa:1|# (import (lib shadchen-helpers))
>
> The above works fine. However, in a fresh interpreter:
>
> #|kawa:1|# (import (lib shadchen))
> /home/toups/work/games/jmonkey3d-lacraw/src/lib/shadchen.scm:9:4:
> unknown library (lib shadchen-helpers)
> /home/toups/work/games/jmonkey3d-lacraw/src/lib/shadchen.scm:110:6:
> warning - no declaration seen for pattern-bindings-equal?
> /home/toups/work/games/jmonkey3d-lacraw/src/lib/shadchen.scm:117:6:
> warning - no declaration seen for all-identifiers?
>
> The import fails because the library reference to shadchen-helpers
> fails to resolve. That reference in `shadchen.scm` looks like this:
>
> (import (except (kawa base) match)
> (kawa lib std_syntax)
> (srfi 28)
> (rnrs sorting (6))
> (rnrs hashtables (6))
> (lib shadchen-helpers))
>
> I have noticed that importing shadchen-helpers at the repl first and
> then importing shadchen works. I would guess because importing the
> shadchen-helpers library compiles that library and then the import
> form in the r7rs define-library can then find the compiled artifact.
>
> But doesn't it make sense for the import form in shadchen to trigger
> the compilation of shadchen-helpers so that it behaves the same as a
> top-level import? Is there any way I can get this behavior? It seems
> limiting to interactive development to have to have either a build
> process or a script to import all libraries despite an explicit
> dependency graph existing in the form of the import statements in the
> library definitions?
>
> I'm relatively new to Kawa and a little rusty in Java (long time
> Schemer, though) so maybe I'm missing something.
>
> -V



      reply	other threads:[~2021-02-06 17:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-05 14:21 J. Vincent Toups
2021-02-06 17:04 ` spellcard199 [this message]

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to='BJiQOnJGWAvYRvlZdzpt-1QAqLH8Z6GFXXQPawwSkRuIWpFlB1y1zdnjA6UU6797haKnL5VTERoddIP0iUzisEXkYY--VqJNpsjG5vyv6KE=@protonmail.com' \
    --to=spellcard199@protonmail.com \
    --cc=kawa@sourceware.org \
    --cc=vincent.toups@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

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