R7RS Libraries and Java interaction

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

R7RS Libraries and Java interaction

Peter Lane
Hi,

Is it possible to make an R7RS library recognise Java interaction when
compiled?

e.g. if I try compiling the following:

(define-library (java)
                 (export get-num)
                 (import (scheme base))

                 (begin
                   (define (get-num) ((String "hello"):length))
                 ))

$ kawa --r7rs -C java.sld(compiling java.sld to java)
java.sld:7:54: warning - no declaration seen for :length

$ kawa --r7rs try-java.sps java.sld:7:54: unbound location: :length
     at gnu.mapping.SharedLocation.get(SharedLocation.java:22)
     at gnu.mapping.DynamicLocation.get(DynamicLocation.java:28)
     at java.getNum(java.sld:7)

If I rewrite get-num to use invoke, I still get compilation warnings,
but it works at runtime.


If the answer's no, that's ok: I think Kawa's modules will interact all
right with my other code.  I'm just partial to the R7RS form.

   thanks for any suggestions

        Peter.

--
Peter Lane
http://peterlane.info/scheme.html

Reply | Threaded
Open this post in threaded view
|

Re: R7RS Libraries and Java interaction

Per Bothner
On 03/22/2017 01:55 PM, Peter Lane wrote:

> Is it possible to make an R7RS library recognise Java interaction when compiled?
>
> e.g. if I try compiling the following:
>
> (define-library (java)
>                 (export get-num)
>                 (import (scheme base))
>
>                 (begin
>                   (define (get-num) ((String "hello"):length))
>                 ))
>
> $ kawa --r7rs -C java.sld(compiling java.sld to java)
> java.sld:7:54: warning - no declaration seen for :length

It seems to work if you leave off the --r7rs flag.

The --r7rs disables features that conflict with R7RS, such as the special
meaning of colon, since in R7RS colon is just a regular symbol character.
You don't need it for this example.

> $ kawa --r7rs try-java.sps java.sld:7:54: unbound location: :length
>     at gnu.mapping.SharedLocation.get(SharedLocation.java:22)
>     at gnu.mapping.DynamicLocation.get(DynamicLocation.java:28)
>     at java.getNum(java.sld:7)
>
> If I rewrite get-num to use invoke, I still get compilation warnings, but it works at runtime.

That can be fixed by adding:

    (import (only (kawa base) invoke))
--
        --Per Bothner
[hidden email]   http://per.bothner.com/