`this` in concise method bodies

forax at univ-mlv.fr forax at univ-mlv.fr
Sat Oct 13 09:04:28 UTC 2018

> De: "John Rose" <john.r.rose at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Brian Goetz" <brian.goetz at oracle.com>, "amber-spec-experts"
> <amber-spec-experts at openjdk.java.net>
> Envoyé: Samedi 13 Octobre 2018 07:00:09
> Objet: Re: `this` in concise method bodies

> On Oct 12, 2018, at 12:58 PM, Remi Forax < [ mailto:forax at univ-mlv.fr |
> forax at univ-mlv.fr ] > wrote:

>> 1) They are few methods that can be converted to concise methods because the
>> implementation has to be a one liner,
>> 2) They are very few methods that can be converted to a concise methods that
>> that use the :: syntax because it only works if the implementation delegates to
>> a method that uses all the parameters in the same order,
>> 3) They are very very few methods that can be converted to a concise methods
>> that use the :: and use 'this' explicitly as first parameter.

>> so before descending into the rabbit hole, i think not me|someone should check
>> how many methods can be converted to use the :: + this syntax in big corpus of
>> Java codes.

> This is probably true, because Java programmers have limited tools
> for software reuse: Inheritance and explicit subroutine calls. If they
> had the ability to connect methods directly using CMBs, the source
> base would look different. There would be less cut-and-paste. A true
> mechanical analysis of the applicability of CMBs to connect methods
> would have to disregard lots of hand-crafted of method calls, and
> unwind uses of inheritance where delegation (had it been available
> at the time) would have been a better choice.

I agree, contrasting the code of java.util.stream with the code of the collection of java.util is a good exercise to see where CMB can shine. 
But for me, this is an argument to introduce (2) not (3). 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20181013/4a3432ad/attachment-0001.html>

More information about the amber-spec-experts mailing list