Allow lambdas to implement abstract classes

Howard Lovatt howard.lovatt at gmail.com
Sun Mar 3 13:49:56 PST 2013


On 02/03/2013, at 1:23 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:

> On Mar 1, 2013, at 2:10 PM, Howard Lovatt <howard.lovatt at gmail.com> wrote:
>> I remember the previous discussion and just retread it to be sure. The issue raised is with constructors that take arguments or throw checked exceptions.
> 
> Or constructors that execute code with some side-effects.
> 
> 
>> You could limit the lambdas to either functional abstract classes that:
>> 
>> 1. Do not have any user supplied constructors
>> 2. Either 1 above or has a user supplied no-arg constructor that does no throw a checked exception
> 
> And super classes need to be taken into account.
> 
> Functional Interfaces are dead simple to grok. 
> 
> Including a restricted form of class that is a functional abstract class adds another dimension for developers, compilers, runtime and tools to understand. Is it worth it?

Is it worth it? Is the question I am asking. I have found a few examples were it would be useful, even if it was the most restrictive form were the constructor has to be supplied by the compiler. I think it is interesting to explore whether other people have had the same experience and whether these examples are important. 

From my experimentation the uses of abstract class SAMs is primarily for optimisation since you can always wrap the lambda in a class. I would count optimisation as important particularly for parallel collections, one of the key use cases for lambdas.

What do others think, is optimisation important?

 -- Howard. 

> 
> Paul.
> 
>> Option 1. Is the most conservative, would the be an objection to 1. 
>> 
>> -- Howard. 
>> 
>> Sent from my iPad
>> 
>> On 01/03/2013, at 9:19 PM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>> 
>>> Hi Howard,
>>> 
>>> Abstract classes have constructors that will execute user code and thus they can observe and interfere with the process of bootstrapping the lambda expressions. See the following thread for more details:
>>> 
>>> http://mail.openjdk.java.net/pipermail/lambda-dev/2012-November/006436.html
>>> 
>>> Paul.
>>> 
>>> On Mar 1, 2013, at 2:54 AM, Howard Lovatt <howard.lovatt at gmail.com> wrote:
>>>> 
>>>> Would it be useful in other cases if lambdas could implement abstract
>>>> methods?
>>>> 
>>>> -- Howard.
> 
> 


More information about the lambda-dev mailing list