Updated State of the Lambda

Ali Ebrahimi ali.ebrahimi1781 at gmail.com
Sat Oct 16 05:42:36 PDT 2010


I think chained method invocations is very common in java and that is one of
its advantages, thus this limitation is worth fixed very soon.

best regards,
Ali

On Sat, Oct 16, 2010 at 1:57 PM, maurizio cimadamore <
maurizio.cimadamore at oracle.com> wrote:

>  On 16/10/2010 06:36, Ali Ebrahimi wrote:
>
>> looks fine. another step to real closures.
>>
>> but one question. if we can not improve the inference scheme to support
>> following sample code?
>>
>>  Hi Ali
> I think the new semantics of this is very polished and removes many complex
> interactions between the lambda body and the target type which, in turn
> should allow for better inference. That alone, however, won't be enough to
> make this example work. In this specific case I think that the inference
> changes required in order to make things work are deeper than it might seem
> - as I said in a related post, the problem with inference in chained method
> invocations _is_ a problem in the Java language as currently specified,
> regardless of lambda (i.e. you could write examples w/o lambda that exhibit
> the same problem). With lamba things get a lot worse since chained calls are
> very common in certain kinds of libraries, and of course we need a better
> inference story in order to allow that.
>
> Maurizio
>
>> public class Test
>> {
>>    public static class Customer {
>>       public String getName() { return "";}
>>    }
>>    public abstract static class StringSorter<U>  {
>>       abstract String value(U val);
>>    }
>>    public static interface Select<U, V>  {
>>       public V select(U val);
>>    }
>>    public static class DBSet<T>   {
>>       public<U>  DBSet<U>  select(Select<T,U>  x) {return new DBSet<U>();}
>>       public DBSet<T>  sortedByStringAscending(StringSorter<T>  x) {return
>> this;}
>>    }
>>
>>    public static DBSet<Customer>  allCustomer()
>>    {
>>       return new DBSet<Customer>();
>>    }
>>
>>    public static void main(String[] args)
>>    {
>>       DBSet<String>  result = allCustomer()   //DBSet<Customer>
>>          .select(#{c ->  c.getName()})      // This line fails in compile
>> time
>>          .sortedByStringAscending(#{str ->  str});
>>
>>    }
>> }
>>
>>
>> On Fri, Oct 15, 2010 at 11:25 PM, Brian Goetz<brian.goetz at oracle.com
>> >wrote:
>>
>>
>>  An updated draft (Version 3) of the State of the Lambda has been
>>> published
>>> at:
>>>
>>>   http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-3.html
>>>
>>> Notable differences from the previous draft include:
>>>  - 'this' in lambda expressions is lexically scoped
>>>  - 'yield' keyword dropped in favor of 'return'
>>>  - new syntax
>>>
>>> Maurizio will be pushing an implementation conforming to this draft soon.
>>>
>>>
>>>
>>>
>


More information about the lambda-dev mailing list