> De: "John Rose" <john.r.r...@oracle.com> > À: "Brian Goetz" <brian.go...@oracle.com> > Cc: "Remi Forax" <fo...@univ-mlv.fr>, "Tagir Valeev" <amae...@gmail.com>, > "amber-spec-experts" <amber-spec-experts@openjdk.java.net> > Envoyé: Jeudi 4 Mars 2021 08:17:41 > Objet: Re: [External] : Pattern assignment statements (extracted from: > Primitive > type patterns and conversions)
> On Mar 3, 2021, at 8:09 AM, Brian Goetz < [ mailto:brian.go...@oracle.com | > brian.go...@oracle.com ] > wrote: >>> the whole story about initializing a local variable with an array is weird, >>> int data[] = {1, 2, 3}; >>> compiles but >>> int data[]; >>> data = {1, 2, 3}; >>> does not. >> True, and I hate it. This is related to the C-style array decl; for the first >> year it was really important that Java seem friendly to C developers, and >> this >> was one of the compromises. For the rest of time, it is just an annoying >> irregularity. > Here are some thoughts on array handling > and patterns. > Basically, looking at pattern assignment, in > the case of arrays, prompts me to think that > the more rewarding goal is pattern declarations, > not pattern assignments. So I’ll try to compare > and contrast those, for arrays and other kinds of > patterns. > Backing up… > First, I agree with Brian that “int data[] = …” > is horrible; we should have only allowed > “int[] data = …” and taken the hit early. There is also its big brother int foo() [] { return null; } which is the epitome of the C-style array declaration allowed in Java. Rémi