public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Using Kawa extensions in R7RS libraries
@ 2015-02-12  9:27 Helmut Eller
  2015-02-12 17:57 ` Per Bothner
  0 siblings, 1 reply; 13+ messages in thread
From: Helmut Eller @ 2015-02-12  9:27 UTC (permalink / raw)
  To: kawa

I supposed it's possible to import Kawa extensions into
R7RS libraries like so:

 (define-library (foo)
   (import (only <some-library> invoke invoke-static field static-field))
   ...)

But what is the name of <some-library> that exports the various Kawa
extensions?

Howev

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-02-12  9:27 Using Kawa extensions in R7RS libraries Helmut Eller
@ 2015-02-12 17:57 ` Per Bothner
  2015-02-15 20:49   ` Helmut Eller
  0 siblings, 1 reply; 13+ messages in thread
From: Per Bothner @ 2015-02-12 17:57 UTC (permalink / raw)
  To: kawa



On 02/12/2015 01:27 AM, Helmut Eller wrote:
> I supposed it's possible to import Kawa extensions into
> R7RS libraries like so:
>
>   (define-library (foo)
>     (import (only <some-library> invoke invoke-static field static-field))
>     ...)
>
> But what is the name of <some-library> that exports the various Kawa
> extensions?

I think we could start with:
   (kawa reflect) ; includes invoke invoke-static field static-field and more
   (kawa all) ; everything defined in the default REPL

I'll get to it soon, but if you want to contribute at least (kawa reflect)
it's fairly straightforward. See kawa/lib/prim_imports.scm for how to do it.
We just need to create kawa/lib/kawa/reflect.scm based on that pattern.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-02-12 17:57 ` Per Bothner
@ 2015-02-15 20:49   ` Helmut Eller
  2015-02-17  6:23     ` Per Bothner
  0 siblings, 1 reply; 13+ messages in thread
From: Helmut Eller @ 2015-02-15 20:49 UTC (permalink / raw)
  To: kawa

[-- Attachment #1: Type: text/plain, Size: 842 bytes --]

On Thu, Feb 12 2015, Per Bothner wrote:

> I'll get to it soon, but if you want to contribute at least (kawa reflect)
> it's fairly straightforward. See kawa/lib/prim_imports.scm for how to do it.
> We just need to create kawa/lib/kawa/reflect.scm based on that pattern.

Here are two files reflect.scm and all.scm.  I added to (kawa all) the
stuff that I happened to need; many things that are described in the
manual are missing.  I'm also not sure that (kawa reflect) is very I
usually need the features to access Java libraries and this includes
try-catch and define-simple-class.

When I tried to import (kawa reflect) into (kawa all) I got errors like
 Exception in thread "main" java.lang.NoClassDefFoundError:
   kawa/reflect (wrong name: kawa/lib/kawa/reflect)
I wasn't sure how to fix it, so I just duplicated the imports.

Helmut


[-- Attachment #2: reflect.scm --]
[-- Type: application/emacs-lisp, Size: 696 bytes --]

[-- Attachment #3: all.scm --]
[-- Type: application/emacs-lisp, Size: 2313 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-02-15 20:49   ` Helmut Eller
@ 2015-02-17  6:23     ` Per Bothner
  2015-02-17  6:37       ` Per Bothner
  2015-04-13  5:45       ` Jamison Hope
  0 siblings, 2 replies; 13+ messages in thread
From: Per Bothner @ 2015-02-17  6:23 UTC (permalink / raw)
  To: Helmut Eller, kawa



On 02/15/2015 12:49 PM, Helmut Eller wrote:
> On Thu, Feb 12 2015, Per Bothner wrote:
>
>> I'll get to it soon, but if you want to contribute at least (kawa reflect)
>> it's fairly straightforward. See kawa/lib/prim_imports.scm for how to do it.
>> We just need to create kawa/lib/kawa/reflect.scm based on that pattern.
>
> Here are two files reflect.scm and all.scm.  I added to (kawa all) the
> stuff that I happened to need; many things that are described in the
> manual are missing.  I'm also not sure that (kawa reflect) is very I
> usually need the features to access Java libraries and this includes
> try-catch and define-simple-class.

Thanks.  I checked this in.

I intended (kawa all) to include all the definitions available in the normal
Kawa environment.  So I also imported and re-exported all the (scheme XXX)
libraries.

We might want a different library for all the of the definitions in kawa
but *not* in r7rs - perhaps named (kawa extras) or (kawa non-r7rs).
However, I can't think of a use for this.

I haven't added all the kawa bindings yet - this is a weork-in-progress.
When done we can probably remove all the deinitions in Scheme#initScheme,
instead just do a loadClass of the kawa.lib.scheme.all class thus removing
a bunch of duplication.

> When I tried to import (kawa reflect) into (kawa all) I got errors like
>   Exception in thread "main" java.lang.NoClassDefFoundError:
>     kawa/reflect (wrong name: kawa/lib/kawa/reflect)
> I wasn't sure how to fix it, so I just duplicated the imports.

I fixed this by adding a catch to ignore this Error.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-02-17  6:23     ` Per Bothner
@ 2015-02-17  6:37       ` Per Bothner
  2015-04-13  5:45       ` Jamison Hope
  1 sibling, 0 replies; 13+ messages in thread
From: Per Bothner @ 2015-02-17  6:37 UTC (permalink / raw)
  To: kawa



On 02/16/2015 10:23 PM, Per Bothner wrote:
> I intended (kawa all) to include all the definitions available in the normal
> Kawa environment.  So I also imported and re-exported all the (scheme XXX)
> libraries.

On second thoughts, this should probably be (kawa base).  Calling it '(kawa all)'
implies including every single library, and I don't think we want
everything to be defined by default.

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-02-17  6:23     ` Per Bothner
  2015-02-17  6:37       ` Per Bothner
@ 2015-04-13  5:45       ` Jamison Hope
  2015-04-13  7:32         ` Per Bothner
  1 sibling, 1 reply; 13+ messages in thread
From: Jamison Hope @ 2015-04-13  5:45 UTC (permalink / raw)
  To: kawa@sourceware.org list

[-- Attachment #1: Type: text/plain, Size: 624 bytes --]

On Feb 17, 2015, at 1:23 AM, Per Bothner <per@bothner.com> wrote:

> On 02/15/2015 12:49 PM, Helmut Eller wrote:
>> Here are two files reflect.scm and all.scm.  I added to (kawa all) the
>> stuff that I happened to need; many things that are described in the
>> manual are missing.  I'm also not sure that (kawa reflect) is very I
>> usually need the features to access Java libraries and this includes
>> try-catch and define-simple-class.
> 
> Thanks.  I checked this in.

(kawa reflect) was missing the field setters set-field! and
set-static-field!, patch attached.


--
Jamison Hope
The PTR Group
www.theptrgroup.com



[-- Attachment #2: field-setters.patch --]
[-- Type: application/octet-stream, Size: 1365 bytes --]

Index: kawa/lib/ChangeLog
===================================================================
--- kawa/lib/ChangeLog	(revision 8396)
+++ kawa/lib/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2015-04-13  Jamison Hope  <jrh@theptrgroup.com>
+
+	* kawa/reflect.scm (set-field!, set-static-field!): New exports.
+	* kawa/base.scm (set-field!, set-static-field!): Likewise.
+
 2015-04-05  Jamison Hope  <jrh@theptrgroup.com>
 
 	* kawa/quaternions.scm (vector-quaternion?,
Index: kawa/lib/kawa/base.scm
===================================================================
--- kawa/lib/kawa/base.scm	(revision 8396)
+++ kawa/lib/kawa/base.scm	(working copy)
@@ -32,6 +32,8 @@
 	  invoke-special
 	  field
 	  static-field
+          set-field!
+          set-static-field!
 	  make
 	  instance?
 	  as
Index: kawa/lib/kawa/reflect.scm
===================================================================
--- kawa/lib/kawa/reflect.scm	(revision 8396)
+++ kawa/lib/kawa/reflect.scm	(working copy)
@@ -4,6 +4,8 @@
 	  invoke-special
 	  field
 	  static-field
+          set-field!
+          set-static-field!
 	  make
 	  instance?
 	  as
@@ -23,6 +25,10 @@
 	 field
 	 static-field)
 
+   (only (gnu kawa reflect SlotSet)
+         set-field!
+         set-static-field!)
+
    (only (rename (gnu kawa reflect Throw)
 		 (primitiveThrow primitive-throw))
 	 primitive-throw)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-04-13  5:45       ` Jamison Hope
@ 2015-04-13  7:32         ` Per Bothner
       [not found]           ` <CANfjrNW0FFmM3Xp5gX+BNqAbq2Y=C2OiuHYEXv50Y09r9NWipA@mail.gmail.com>
  0 siblings, 1 reply; 13+ messages in thread
From: Per Bothner @ 2015-04-13  7:32 UTC (permalink / raw)
  To: kawa



On 04/12/2015 10:45 PM, Jamison Hope wrote:

> (kawa reflect) was missing the field setters set-field! and
> set-static-field!, patch attached.

Thanks - checked in.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
       [not found]           ` <CANfjrNW0FFmM3Xp5gX+BNqAbq2Y=C2OiuHYEXv50Y09r9NWipA@mail.gmail.com>
@ 2015-07-05 16:18             ` Per Bothner
  2015-07-06  7:30               ` Elías Alonso G.-Cornejo
  0 siblings, 1 reply; 13+ messages in thread
From: Per Bothner @ 2015-07-05 16:18 UTC (permalink / raw)
  To: Elías Alonso G.-Cornejo; +Cc: kawa

[-- Attachment #1: Type: text/plain, Size: 930 bytes --]



On 07/05/2015 12:31 AM, Elías Alonso G.-Cornejo wrote:
> I've been having some trouble using
>
> (object ...)
>
> to create anonymous classes inside
>
> (define-library ...)
>
> declarations. I've added (import (kawa base)), but Kawa tries to
> instantiate java.lang.Object instead of creating the anonymous class.
> Where is the (object ...) macro defined? I've looking in lib/kawa,
> but can't find it.

The object macro is implemented by the Java code kawa/standard/object.java.
(You can see this by searching for "object" in kawa/standard/Scheme.java.)

It looks like 'object' is missing in (kawa base).  Please try the
attached patch and let me know if that fixes the issue.

We need to systematically go through the kawa extensions and add
them to (kawa base).  (We should also re-do the bindings in Scheme.java
to use (kawa base) rather than duplicate it.)
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

[-- Attachment #2: obj.patch --]
[-- Type: text/x-patch, Size: 518 bytes --]

Index: kawa/lib/kawa/base.scm
===================================================================
--- kawa/lib/kawa/base.scm	(revision 8556)
+++ kawa/lib/kawa/base.scm	(working copy)
@@ -25,6 +25,7 @@
 
 	  define-class
 	  define-simple-class
+          object
 	  this
 
 	  invoke
@@ -105,6 +106,9 @@
 		 (define_class define-class))
 	 define-simple-class define-class)
 
+   (only (kawa standard object)
+         (objectSyntax object))
+
    (only (rename (kawa standard thisRef)
 		 (thisSyntax this))
 	 this)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-07-05 16:18             ` Per Bothner
@ 2015-07-06  7:30               ` Elías Alonso G.-Cornejo
  2015-07-08 14:11                 ` Elías Alonso G.-Cornejo
  2015-07-13  0:16                 ` Per Bothner
  0 siblings, 2 replies; 13+ messages in thread
From: Elías Alonso G.-Cornejo @ 2015-07-06  7:30 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa mailing list

The patch works correctly but raises another issue: (future ...) and
(runnable ...) are not included in (kawa base). I don't know if they
should be included, but if I require kawa/lib/thread.scm with (import
thread), any attempt to call (future ...) will show the following
message:

warning - no declaration seen for lambda

And fail. I fixed it by adding (import (scheme base)) at the top of
kawa/lib/thread.scm but I'm not sure if that's the best way to do it.

> The object macro is implemented by the Java code kawa/standard/object.java.
> (You can see this by searching for "object" in kawa/standard/Scheme.java.)

Thanks, I appreciate the directions. I've tried to read kawa's source
code before, but didn't know where to begin. kawa/standard/Scheme.java
looks like a good starting point :)

2015-07-05 18:17 GMT+02:00 Per Bothner <per@bothner.com>:
>
>
> On 07/05/2015 12:31 AM, Elías Alonso G.-Cornejo wrote:
>>
>> I've been having some trouble using
>>
>> (object ...)
>>
>> to create anonymous classes inside
>>
>> (define-library ...)
>>
>> declarations. I've added (import (kawa base)), but Kawa tries to
>> instantiate java.lang.Object instead of creating the anonymous class.
>> Where is the (object ...) macro defined? I've looking in lib/kawa,
>> but can't find it.
>
>
> The object macro is implemented by the Java code kawa/standard/object.java.
> (You can see this by searching for "object" in kawa/standard/Scheme.java.)
>
> It looks like 'object' is missing in (kawa base).  Please try the
> attached patch and let me know if that fixes the issue.
>
> We need to systematically go through the kawa extensions and add
> them to (kawa base).  (We should also re-do the bindings in Scheme.java
> to use (kawa base) rather than duplicate it.)
>
> --
>         --Per Bothner
> per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-07-06  7:30               ` Elías Alonso G.-Cornejo
@ 2015-07-08 14:11                 ` Elías Alonso G.-Cornejo
  2015-07-12 23:38                   ` Per Bothner
  2015-07-13  0:16                 ` Per Bothner
  1 sibling, 1 reply; 13+ messages in thread
From: Elías Alonso G.-Cornejo @ 2015-07-08 14:11 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa mailing list

The bitwise operators are missing from (kawa base) too.

2015-07-06 9:29 GMT+02:00 Elías Alonso G.-Cornejo <eliasagc@gmail.com>:
> The patch works correctly but raises another issue: (future ...) and
> (runnable ...) are not included in (kawa base). I don't know if they
> should be included, but if I require kawa/lib/thread.scm with (import
> thread), any attempt to call (future ...) will show the following
> message:
>
> warning - no declaration seen for lambda
>
> And fail. I fixed it by adding (import (scheme base)) at the top of
> kawa/lib/thread.scm but I'm not sure if that's the best way to do it.
>
>> The object macro is implemented by the Java code kawa/standard/object.java.
>> (You can see this by searching for "object" in kawa/standard/Scheme.java.)
>
> Thanks, I appreciate the directions. I've tried to read kawa's source
> code before, but didn't know where to begin. kawa/standard/Scheme.java
> looks like a good starting point :)
>
> 2015-07-05 18:17 GMT+02:00 Per Bothner <per@bothner.com>:
>>
>>
>> On 07/05/2015 12:31 AM, Elías Alonso G.-Cornejo wrote:
>>>
>>> I've been having some trouble using
>>>
>>> (object ...)
>>>
>>> to create anonymous classes inside
>>>
>>> (define-library ...)
>>>
>>> declarations. I've added (import (kawa base)), but Kawa tries to
>>> instantiate java.lang.Object instead of creating the anonymous class.
>>> Where is the (object ...) macro defined? I've looking in lib/kawa,
>>> but can't find it.
>>
>>
>> The object macro is implemented by the Java code kawa/standard/object.java.
>> (You can see this by searching for "object" in kawa/standard/Scheme.java.)
>>
>> It looks like 'object' is missing in (kawa base).  Please try the
>> attached patch and let me know if that fixes the issue.
>>
>> We need to systematically go through the kawa extensions and add
>> them to (kawa base).  (We should also re-do the bindings in Scheme.java
>> to use (kawa base) rather than duplicate it.)
>>
>> --
>>         --Per Bothner
>> per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-07-08 14:11                 ` Elías Alonso G.-Cornejo
@ 2015-07-12 23:38                   ` Per Bothner
  0 siblings, 0 replies; 13+ messages in thread
From: Per Bothner @ 2015-07-12 23:38 UTC (permalink / raw)
  To: Elías Alonso G.-Cornejo; +Cc: kawa mailing list

On 07/08/2015 07:10 AM, Elías Alonso G.-Cornejo wrote:
> The bitwise operators are missing from (kawa base) too.

I added those, and checked in the addition of object.

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-07-06  7:30               ` Elías Alonso G.-Cornejo
  2015-07-08 14:11                 ` Elías Alonso G.-Cornejo
@ 2015-07-13  0:16                 ` Per Bothner
  2015-07-13  9:11                   ` Elías Alonso G.-Cornejo
  1 sibling, 1 reply; 13+ messages in thread
From: Per Bothner @ 2015-07-13  0:16 UTC (permalink / raw)
  To: Elías Alonso G.-Cornejo; +Cc: kawa mailing list

On 07/06/2015 12:29 AM, Elías Alonso G.-Cornejo wrote:
> The patch works correctly but raises another issue: (future ...) and
> (runnable ...) are not included in (kawa base).

'runnable' appears to have been in (kawa base).
I also added 'future' and 'sleep.'

I don't know if they
> should be included, but if I require kawa/lib/thread.scm with (import
> thread), any attempt to call (future ...) will show the following
> message:
>
> warning - no declaration seen for lambda
>
> And fail. I fixed it by adding (import (scheme base)) at the top of
> kawa/lib/thread.scm but I'm not sure if that's the best way to do it.

Yes, that is the correct idea, though I used prim_imports instead.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using Kawa extensions in R7RS libraries
  2015-07-13  0:16                 ` Per Bothner
@ 2015-07-13  9:11                   ` Elías Alonso G.-Cornejo
  0 siblings, 0 replies; 13+ messages in thread
From: Elías Alonso G.-Cornejo @ 2015-07-13  9:11 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa mailing list

Thanks!

2015-07-13 2:16 GMT+02:00 Per Bothner <per@bothner.com>:
> On 07/06/2015 12:29 AM, Elías Alonso G.-Cornejo wrote:
>>
>> The patch works correctly but raises another issue: (future ...) and
>> (runnable ...) are not included in (kawa base).
>
>
> 'runnable' appears to have been in (kawa base).
> I also added 'future' and 'sleep.'
>
> I don't know if they
>>
>> should be included, but if I require kawa/lib/thread.scm with (import
>> thread), any attempt to call (future ...) will show the following
>> message:
>>
>> warning - no declaration seen for lambda
>>
>> And fail. I fixed it by adding (import (scheme base)) at the top of
>> kawa/lib/thread.scm but I'm not sure if that's the best way to do it.
>
>
> Yes, that is the correct idea, though I used prim_imports instead.
>
> --
>         --Per Bothner
> per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-07-13  9:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-12  9:27 Using Kawa extensions in R7RS libraries Helmut Eller
2015-02-12 17:57 ` Per Bothner
2015-02-15 20:49   ` Helmut Eller
2015-02-17  6:23     ` Per Bothner
2015-02-17  6:37       ` Per Bothner
2015-04-13  5:45       ` Jamison Hope
2015-04-13  7:32         ` Per Bothner
     [not found]           ` <CANfjrNW0FFmM3Xp5gX+BNqAbq2Y=C2OiuHYEXv50Y09r9NWipA@mail.gmail.com>
2015-07-05 16:18             ` Per Bothner
2015-07-06  7:30               ` Elías Alonso G.-Cornejo
2015-07-08 14:11                 ` Elías Alonso G.-Cornejo
2015-07-12 23:38                   ` Per Bothner
2015-07-13  0:16                 ` Per Bothner
2015-07-13  9:11                   ` Elías Alonso G.-Cornejo

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