Inferring lambda parameter types in an argument position

Neal Gafter neal at gafter.com
Fri Mar 4 22:31:21 PST 2011


I'm aware this is not a new issue.  But it is ripe.

On Friday, March 4, 2011, Ali Ebrahimi <ali.ebrahimi1781 at gmail.com> wrote:
> 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