This is the mail archive of the kawa@sourceware.org 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]
Other format: [Raw text]

Re: rough support for parameterized types in Kawa


On 07/25/2011 01:58 AM, Helmut Eller wrote:
Can we expect function types anytime soon?
I'd like to write something like

(define (foo f::(function object ->  int) x)::int
   (f x))

At some point, but probably not soon. There are a number of issues.


Even if Kawa has an function type, you still need some way to encode
if in class files.  The obvious way is to use a generic type.  One
problem is that we don't have varargs in generics.  Function types with a
say 2 parameters can use a predefined Generic class Function2, ,making
use of wildcards.  To support the general case you either need a
custom ClassLoader than can generate the neded generic classes
on-the-fly, or you use so encoding so that (X1, X2, X3)->R
is encodeded as Function(ArgPair(X1, ArgPair(X2, Arg1(X3))), R).
The latter is weird, but could be used as an encoding format at least.

Another issue is how do keyword and rest parameter get function types?
How are they represented?  How are they type-checked?   One could just
punt: keyword/rest function are treated as a catch-all varargs function
type, while we handle proper function types for plain fixargs functions.

What is the overloading of a generic (in the Lisp sense) function?  A
union of function types?  How does one type-check those?

Avoiding boxing for primitive arguments or returns adds another compilation.
That would seem to require a custom interface for each function type.
Or some rather creative use of generic types.  Either might need a custom
class-loader.  Perhaps using JSR 292 MethodTypes is the right way.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


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