Not Dead Yet (was: MethodHandle vs function types)
Howard Lovatt
howard.lovatt at gmail.com
Wed Feb 24 12:53:18 PST 2010
Neal Gafter Said
> Approach (1) doesn't work for various reasons. As we've already seen by the
> failure of Howard Lovatt's attempt to reify function types, we must preserve
> reference identity for all widening reference conversions.
I would say this is overstating the problems. To amplify their are two
areas in which reference identity are not conserved:
1. If you have:
#String(Object) so = #(Object o)(o.toString());
#Object(String) os = so;
Then os == so is false, but os.equals(so) is true. This is little
different than comparing many reference types,
e.g. String, and therefore I think OK.
2. If, as my suggestion is currently written, you have:
#String(Object)[] soa = new #String(Object)[1];
#Object(String)[] osa = soa;
Then osa == soa is false. This is indeed a problem since osa[0] =
#(Object o)(o.toString()) will not set soa[0] also.
As I said in a previous email, I am thinking about the best
solution to this. One possibility is that the above example is
translated into:
_Callable_1<? extends String, ? super Object>[] soa =
(_Callable_1<? extends String, ? super Object>[]) new _Callable_1[1];
_Callable_1<? extends Object, ? super String>[] osa = soa;
IE arrays are erased not reified. This is probably OK, but there
may well be a better solution and I am still considering other
options.
Therefore I would say, with apologies to Monty Python, that reified
lambdas are "not dead yet".
-- Howard.
More information about the lambda-dev
mailing list