Inferring lambda parameter types in an argument position
Ali Ebrahimi
ali.ebrahimi1781 at gmail.com
Fri Mar 4 21:30:18 PST 2011
Hi all,
+1,
This may be duplicate of this
http://mail.openjdk.java.net/pipermail/lambda-dev/2010-October/002488.html
Best Regards,
Ali Ebrahimi
On Fri, Mar 4, 2011 at 10:46 PM, Neal Gafter <neal at gafter.com> 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.
>
> 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