Inferring lambda parameter types in an argument position
Neal Gafter
neal at gafter.com
Fri Mar 4 11:16:09 PST 2011
Dear Lambda-
I'd like the lambda conversion to infer lambda parameter types even when the
lambda appears in an argument position and the underlying method is
overloaded.
For example, given
*interface Mapping<In, Out>
{
Out map(In in);
}
interface IndexedMapping<In, Out>
{
Out map(In in, int index);
}
interface Predicate<E>
{
bool isSatisfied(E e);
}
interface MyList<E> {
<U> MyList<U> map(Mapping<? super E, ? extends U> f) ...;
<U> MyList<U> map(IndexedMapping<? super E, ? extends U> f) ...;
MyList<E> filter(Predicate<? super E> p) ...
}
*
I would like to be able to write my lambdas with parameter types elided:
*
*
*MyList<X> list = ...;*
*MyList<Y> newList = list
.map( #{ x -> new Y(x) } )
.filter( #{ y -> y.IsFunny() } );*
This is all modulo syntax. I'd prefer the syntax
*MyList<Y> newList = list
.map( x -> new Y(x) )
.filter( y -> y.IsFunny() );
*
but that is a discussion for another day (just let us know which day).
Cheers,
Neal
More information about the lambda-dev
mailing list