[External] : Pattern assignment statements (extracted from: Primitive type patterns and conversions)

forax at univ-mlv.fr forax at univ-mlv.fr
Thu Mar 4 07:52:17 UTC 2021

> De: "John Rose" <john.r.rose at oracle.com>
> À: "Brian Goetz" <brian.goetz at oracle.com>
> Cc: "Remi Forax" <forax at univ-mlv.fr>, "Tagir Valeev" <amaembo at gmail.com>,
> "amber-spec-experts" <amber-spec-experts at 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.goetz at oracle.com |
> brian.goetz at 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. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20210304/0226e4c8/attachment.htm>

More information about the amber-spec-experts mailing list