Method references with types [Re: lambda syntax tutorial]
Paul Benedict
pbenedict at apache.org
Thu Aug 5 14:32:59 PDT 2010
My point is these two automatic conversions would be pretty cool. Just to
continue Brian's example:
interface Extractor<T, U> {
public U get(T t);
}
class Arrays {
public <T, U extends Comparable<? super U>>
void sortBy(T[] array, Extractor<T, U> extractor) { ... }
}
// automatic SAM conversion
Arrays.sortBy(strings, String#length());
// automatic reflected method conversion
java.lang.reflect.Method m = String#length();
Paul
On Thu, Aug 5, 2010 at 4:30 PM, Rémi Forax <forax at univ-mlv.fr> wrote:
> Le 05/08/2010 23:03, Paul Benedict a écrit :
> > Good point Stephen. Parentheses should refer to methods, and without them
> to
> > fields. Your insight will definitely retain the separate namespaces that
> > Java has established.
> >
> > PS: Is Lambda also considering any support to turn method/field
> references
> > into java.lang.reflect types?
> >
>
> JSR 292 already adds support for instance field/static field references
> in the VM.
> The question is just, should they have a syntax in Java.
>
> Rémi
>
>
More information about the lambda-dev
mailing list