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]

Re: Kawa Servlets


Per Bothner wrote:

> Well, that is a bit tricky, because the CLOS object model is very
> different from Java's.  Specifically, CLOS does not have object methods,
> it only has methods that are part of generic functions.  CLOS classes
> have slots, but no methods.  It is plausible to map "properties" (i.e.
> either public fields or getXXX/setXXX pairs as in JavaBeans) to "slots".
> But automatically mapping methods to generic functions is more difficult.

It seems to me that the CLOS model is a super-set of the Java model,
because CLOS is multi-dispatch and Java is single dispatch. I know that
in CLOS methods don't "belong" to a class like they do in Java.

My logic seems to run as follows:

1) We need CLOS.

2) We need at least the option for single dispatch CLOS class/method
groups to map to a Java class. In this case we are willing to accept
some hacks and ugliness to make it happen. e.g. restriction that methods
must be in same source file. Or whatever hack is necessary.

3) If we have (2) then auto-generated CLOS style interface seems
straight-forward. Just generate a CLOS class and appropriate generic
functions.
 
> While I do have plans to implement CLOS-style classes in Kawa
> (see http://www.bothner.com/~per/papers/jaoo99.html), that involves
> translating CLOS-like Scheme code to Java classes.  Going the other
> way may not make sense.

Since CLOS is more of a super set I would think going the other way
makes at least as much sense.

>  In that case it may make more sense use
> classes-with-methods - which I also intend to support.  In fact you
> can already do that quite conventiently, using the `make', `invoke',
> and `invoke-static' functions, so I'm not quite sure what people are
> asking for.

Partly because "invoke" itself is rather annoying. Partly because to use
many Java classes requires inheriting from them. E.g. to write a Servlet
you have to inherit from "Servlet". Is this actually possible in Kawa
right now? On a quick browse of the doco I couldn't see it.

In an ideal world I think there is a CLOS system. Java classes are CLOS
objects with single dispatch. You can define your own objects with
multi-dispatch. If you inherit a Java class with a new CLOS object it
works in the obvious way. Like I was saying, I'd like to be able to just
say....

(define-class MyServlet (Servlet)
...)

(define-method doGet (MyServlet)
...)

and have everything work, without having to write any mapping code.

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