Boxing function types
neal at gafter.com
Sun Nov 22 08:25:28 PST 2009
This is an interesting idea, but you have the variance backwards for
argument types. The argument types in the function on the right-hand-side
of the assignment must be subtypes (not supertypes) of the argument types in
the function on the left-hand-side.
2009/11/21 Kochurov Alexander <ipris at inbox.ru>
> what about introducing boxing/unboxing for functional types?
> As Java generics don't allow us to use primitive types as type parameters,
> all java implementations of collection algorithms (such as map, fold,
> filter, etc.) would possibly use wrapper types such as Integer, Float and
> function types with wrapper arguments.
> So it would be great if every function type with argument types A,
> A,.. A[n] and result type Ra may be implicitly boxed into any other
> function type with argument types B, B, .. B[n] and result type Rb if
> either A[i] = B[i] or A[i] can be converted into B[i] using implicit
> convertion for any i = 1..n and if it's result type Ra either matches Rb or
> may be converted implicitly.
> (So I mean not only boxing/unboxing but also widening convertions for
> primitive types, e.g. function with result of short may be converted
> implicitly into function which returns int, long, float, double, Short,
> Integer, Long, Float, Double but not byte, Byte, etc.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the closures-dev