Function types versus arrays
Howard Lovatt
howard.lovatt at iee.org
Mon Feb 8 17:33:01 PST 2010
If you have reified lambdas then you don't have a problem, if you have
erased lambdas then it is the same as generics. I would favor reified
lambdas so that the following happens:
#int()[] ils = new #int()[1];
ils[0] = #double() (1); // error
But if erased lambdas are used then you need a notation for the raw type of
a lambda, just like generics. Perhaps # on its own, e.g.:
#[] ls = new #[1];
ls = #double() (1); // ok
#int()[] ils = (#int()) new #[1]; // issues warning
ils = #double() (1); // error
On 8 February 2010 23:37, Neal Gafter <neal at gafter.com> wrote:
> On Mon, Feb 8, 2010 at 2:52 PM, Howard Lovatt <howard.lovatt at gmail.com>
> wrote:
> > It would be very odd if arrays of function types were not supported,
> > just not Java. The worry about ArrayStoreExceptions is in my
> > experience overstated, it is exceptionally rare and caught at runtime
> > anyway.
>
> The worry is the *absence* of ArrayStoreException when a lambda with
> the wrong type is placed into an array. If we could make it safe at
> runtime by throwing ArrayStoreException, then I wouldn't be worried
> about allowing arrays of function type.
>
--
-- Howard.
More information about the lambda-dev
mailing list