JEP proposed to target JDK 11: 323: Local-Variable Syntax for Lambda Parameters (original) (raw)
forax at univ-mlv.fr forax at univ-mlv.fr
Mon Jan 29 07:00:50 UTC 2018
- Previous message: JEP proposed to target JDK 11: 323: Local-Variable Syntax for Lambda Parameters
- Next message: JEP proposed to target JDK 11: 323: Local-Variable Syntax for Lambda Parameters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
De: "Jonathan Bluett-Duncan" <jbluettduncan at gmail.com> À: "Remi Forax" <forax at univ-mlv.fr> Cc: "jdk-dev" <jdk-dev at openjdk.java.net> Envoyé: Lundi 29 Janvier 2018 01:02:52 Objet: Re: JEP proposed to target JDK 11: 323: Local-Variable Syntax for Lambda Parameters
Hi Rémi,
You may find my (short) response inline.
Hi Johnathan,
On 28 January 2018 at 23:47, Remi Forax < [ mailto:forax at univ-mlv.fr |_ _forax at univ-mlv.fr ] > wrote:
Hi Andrew,
----- Mail original ----- > De: "Andrew Haley" < [ mailto:aph at redhat.com | aph at redhat.com ] >
À: "Zheka Kozlov" < [ mailto:orionllmain at gmail.com | orionllmain at gmail.com ] >, "Martijn Verburg" < [ mailto:martijnverburg at gmail.com |_ _> martijnverburg at gmail.com ] > > Cc: "jdk-dev" < [ mailto:jdk-dev at openjdk.java.net | jdk-dev at openjdk.java.net ] > > Envoyé: Vendredi 26 Janvier 2018 16:09:34 Objet: Re: JEP proposed to target JDK 11: 323: Local-Variable Syntax for Lambda > Parameters
> On 26/01/18 09:59, Zheka Kozlov wrote: >> The motivation is to allow
final
and annotations on lambda parameters:
>> (final var x) → x + 1; >> (@Nonnull var x) → x + 1;
> I'm trying to understand how it makes sense to have something > that's both variable and final.
yes, 'final var' is an odd combination, 'var' means more this is a local variable and less this is something which is variable.
In Java, you can declare a parameter of a method final which means it's a local variable that can be only assigned once, given that parameters are assigned with the calling arguments, it means that this parameter can not be re-assigned. This is just a compile time 'annotation', because marking a parameter or a local variable final is not something which is stored in the classfile (apart if you compile with the -parameters, but most people don't).
Some coding conventions, mostly the one from Google mandates that all method parameters are declared final, so since Java 8, some developers have asked to be able to declare lambda parameters final.
Oh, do Google's coding conventions really mandate this practice? I've had a look through the Google Java Style guide, but I can't seem to find anything to confirm it. Do you have a source that I can check?
Ok, this reply enters in the category of "never post after 1am", so i apologize, i should have checked the resources online before saying something stupid, i've seen code written by Googlers and ex-Googlers and from that i've stupidly thunk that it was Google thing.
Actually, it's worst, after a quick search on the internet, it seems to be a checkstyle rule enables by default, not something written in a guide.
In a perfect World, Google should update its coding convention because mandating to declare local variables final has the nasty side effect of blurring the distinction between final for a field which as you know has effects defined by the memory model and final on local variable which has no effect. So mandating to declare local variables final is harmful.
> -- > Andrew Haley > Java Platform Lead Engineer > Red Hat UK Ltd. < [ https://www.redhat.com/ | https://www.redhat.com ] > > EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
cheers, Rémi
Cheers, Jonathan
regards, Rémi
- Previous message: JEP proposed to target JDK 11: 323: Local-Variable Syntax for Lambda Parameters
- Next message: JEP proposed to target JDK 11: 323: Local-Variable Syntax for Lambda Parameters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]