This is the mail archive of the kawa@sourceware.cygnus.com 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]

Best way to interface Java?


I've been working on my Scheme-JSP.

It's sort of turned into a SAX processor written in Scheme (I
couldn't resist).

It's pretty re-usable but I'm now wondering what the best way of
interfacing Java to it would be so I'm seeking opinions.

Basically it's one proc: 

  (parser port)

but a la SAX it calls other procs:

  (tag-opened tag-name attrib-hash)  ;when a tag is seen to be
"opened"

  (tag-closed tag-name)  ;when a tag is seen to be closed

  (char-data data)  ;when some data gets picked up


I could interface this to Java in a couple of ways:

1. I could pass 3 procs to the parser which do the 3 different
things
This gets to be a bit of pain in the neck when one extends the parser
to identify other events, eg: documentStart and documentEnd

Also it gives no type checking and will fall flat on it's face if a
proc passed in is Proc1 when it should be Proc3.

2. I could expect the various procs to be defined when the module is
loaded
using:
  environment-bound?
on the procs that the parser requires would allow me to throw an
exception or terminate gracefully if they weren't there.

Any Java or Scheme code would therefore have to create the bindings
in the Environment in which it loaded the parser module.

3. I could pass a OO style proc to the parser
The proc would take a symbol parameter and a list. The symbol would
define the action and the list would be the rest of the args.

As for 1. there is no type-checking which puts me off a bit.



I'm trying to keep it as functional as possible and therefore I don't
really want to get involved with using setters.


Does anyone have any views or any other ideas?

I'm aiming for something that looks good in both scheme and java. 

To me: 1 and 3 look bad in java and 2 doesn't look very schemey (but
I'll probably do that if no one can think of anything).


Nic Ferrier

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