Inferring lambda parameter types in an argument position

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Mar 4 12:11:36 PST 2011


Hi Neal,
I think we are on the same page here. The current compiler works 
*almost* fine - only problem is inference in chained calls (i.e. chained 
call to 'filter' in your example) - but we are working on it.

Maurizio

On 04/03/11 19:16, Neal Gafter wrote:
> 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() );
> *



More information about the lambda-dev mailing list