Function types versus arrays

Howard Lovatt howard.lovatt at iee.org
Mon Feb 15 14:12:53 PST 2010


Hi Reinier,

On 13 February 2010 15:22, Reinier Zwitserloot <reinier at zwitserloot.com> wrote:
> On Tue, Feb 9, 2010 at 7:01 AM, Howard Lovatt <howard.lovatt at iee.org> wrote:
>>
>> Well you *speculate* that reified lambdas are type unsound, you haven't
>> and
>> nor has anyone else demonstrated that - in fact quite the opposite.
>
> Well, you *speculate* that disallowing arrays of functional types is 'just
> not java', but you haven't demonstrated that.
> Arrays, really? They're almost deprecated at this point. As long as function
> types are legal in generics, and any usage in arrays is flagged with a clear
> error, I doubt the greater java community is going to get out the tar and
> feathers.

Internally in my classes I still use arrays quite a bit, particularly
arrays of primitives. Alex was asking for what people think about
arrays of lambdas and my feeling is that disallowing them will be yet
another puzzler 101 that will confuse people. This to me is much like
erased generics, sure they have their good points but overall the
reaction is negative because they don't fit seamlessly into the rest
of Java.

>
> However, if function types aren't reified, then arrays are the least of my
> worries. Does that mean something like this:
> void print(#(Number)String formatter, Number number) {
>     System.out.println(formatter.(number));
> }
> void print(#(String)String formatter, String string) {
>     System.out.println(formatter.(string));
> }
> is not legal (if this is done like generics, the signatures are equal
> post-erasure, which is a compile error).

An alternate example might be something like ParallelArray<T> with
specific (fast) reduce methods, i.e.: int reduce(#int(int, int)),
double reduce(#double(double, double)), etc., as well as T
reduce(#T(T, T)). This wouldn't be possible with erased lambdas.

 -- Howard.

>  --Reinier Zwitserloot
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>



-- 
  -- Howard.


More information about the lambda-dev mailing list