Boxing function types

Neal Gafter neal at gafter.com
Sun Nov 22 08:25:28 PST 2009


Kochurov-

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.

Cheers,
Neal

2009/11/21 Kochurov Alexander <ipris at inbox.ru>

> Gentlemens,
>
> 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[1],
> A[2],.. A[n] and result type Ra may be implicitly boxed into any other
> function type with argument types B[1], B[2], .. 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.)
>
> Alex
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20091122/78e253bf/attachment.html 


More information about the closures-dev mailing list