This is the mail archive of the kawa@sourceware.cygnus.com mailing list for the Kawa project. See the Kawa home page for more information.


[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

Re: proposal for Kawa event call-back



Some helpful comments.  Thanks.

> This syntax seems too special case.  I guess I'd like to
> see something close to a "primitive-interface-constructor".

While I don't think it is as special case as you sedm to think,
I do think having a more general syntax would make sense.
Something like:

   (object (SUPERCLASS-AND-INTERFACES ...)
      METHOD-DEF ...))

where a METHOD-DEF might be something like:

	(METHOD-NAME (ARGNAME | (ARGNAME ARGTYPE) ...) [RETURNTYPE] BODY ...)

The "object" form would be equivalent to Java's "new" of an
anonymous inner class.  (There would be a default "magic" constructor,
which makes sure that any "captured" outer variables are accessible.)

I think the "listener" syntax I proposed would be a convenient
short-hand for the more general "object" syntax.

> Suppose I need an event handler for events that have nothing in 
> common with java.awt.event.MouseEvent (this is exactly my case now).  

That is handled by my syntax.  There is nothing special about MouseEvent.
As a *convenience*, the compiler knows about MouseEvent, so it you
specify a mousePressed buttom *and* you don't specify explicit
EVENT-TYPE and interfaces, it will fill those in for you.
But if you have Listener and Event types that the compiler does not
know about, you can specify them explicitly.

> I'd have to list those as "extra", but they aren't extra.

By "extra" interfaces I only mean interfaces that the compiler
can't infer automatically.

> How about this:
>        (primitive-interface-implementor
>         interface (method-assoc-list))
>         Return a new anonymous procedure, which when called will
>         create a new object

While this is Scheme-ish, I really hate all these anonymous procedures.
They add an extra useless layer of parenhesis, and add an extra layer
of abstraction which make it just that harder for most people to
unravel what is going on.

If in most cases, you're just going to call the anonymous procedure
in place, why require the parens?  I believe that is the case here,
which is why I prefer the specify that the syntax creates an
instance, rather than an anonymous procedure.  (If you need an
anonymous procedure, it is easy enough to add an extra lambda.)

More substantively, I'm a little confused by what you mean by
"for each car of each entry in method list will invode the cdr".
*When* is it invoked?  For example, what is the purpose of the classEvent
method?  Who invokes it?

> I'm not sure about mapping the argument list of a java method
> to an arbitrary scheme argument list.  Is it enough to
> generate a stub method that stuffs the arguments into an array
> and then invokes PrimProcedure.applyN() on the PrimProcedure
> object that contains the associated scheme procedure?

I'd prefer to avoid passing arguments through arrays, at
least for fixed-arity methods.  It has a substantial overhead,
and loses whatever type safety you have.  (If you take a
look at kawa/lib in the latest snapshot, you might notice
that Kawa now supposed parameter type specification.
Kawa can now generate more type-correct code, which is both
more efficient and more compatible with Java.)

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner