Inferring lambda parameter types in an argument position
Rémi Forax
forax at univ-mlv.fr
Fri Mar 4 11:28:11 PST 2011
On 03/04/2011 08:16 PM, Neal Gafter wrote:
> 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.
You're not the only one :)
It's on the ToDo list but we haven't discuss yet about that.
Rémi
> 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