A syntax option (function types versus arrays)
Neal Gafter
neal at gafter.com
Mon Mar 1 07:51:03 PST 2010
On Mon, Mar 1, 2010 at 6:19 AM, Gernot Neppert <mcnepp02 at googlemail.com> wrote:
> I may be missing something here, but I don't understand why the
> discussion about type-safety of closures deals only with arrays of
> closures.
Because that is the only aspect of the problem that has implications
for the syntax proposal that started this thread.
> Isn't the root cause for the type-safety-problem the lack of a
> comprehensive runtime-type-info that preserves the entire signature of
> the closure?
> Isn't this exactly the same problem that we're having with erased
> generic types already today?
Yes, exactly. And we can't solve the problem with function types
without solving the problem with generics. Solving the problem with
generics is outside the scope of this project, would require an order
of magnitude more manpower than is devoted to this project, would
require extending the SE 7 schedule by an additional year or two (or
more), and would probably break backward compatibility. None of that
is going to happen.
> I do not see how that differs from a similar situation with closures:
>
> Object obj = #void() { System.out.println("hello world"); };
> #void() closure = (#void())obj;
>
> This should also trigger an 'unchecked' warning, right?
Yes. That is the implication of section 4.7 of lambda's draft specification.
Cheers,
Neal
More information about the lambda-dev
mailing list