Re: Named record pattern

2022-06-01 Thread Brian Goetz
For me, there is a difference between a binding and a local variable, is that bindings are the one declared inside a pattern and a local variables is how a binding is transformed to be usable inside the boby if the pattern match. Our first (wrong) inclination was to treat pattern variables a

Re: Named record pattern

2022-06-01 Thread Remi Forax
> From: "Brian Goetz" > To: "Tagir Valeev" > Cc: "amber-spec-experts" > Sent: Tuesday, May 31, 2022 6:12:06 PM > Subject: Re: Named record pattern > Gavin reminded me that we are not finalizing patterns in switch in 19 (hard to > keep tr

Re: Named record pattern

2022-05-31 Thread Remi Forax
> From: "Maurizio Cimadamore" > To: "Brian Goetz" , "Tagir Valeev" > Cc: "amber-spec-experts" > Sent: Tuesday, May 31, 2022 7:41:21 PM > Subject: Re: Named record pattern > While merging is an issue (if supported), I think early in

Re: Named record pattern

2022-05-31 Thread Maurizio Cimadamore
While merging is an issue (if supported), I think early in the design we settled on the principle that a binding variable should always only have /one/ corresponding declaration (in the places where it is defined). So, from a language perspective, I don’t see an immediate problem, in the sense

Re: Named record pattern

2022-05-31 Thread Brian Goetz
Gavin reminded me that we are not finalizing patterns in switch in 19 (hard to keep track, sometimes), so we have a little bit of time to figure out what we want here. One thing that is potentially confusing is that patterns work indirectly in a number of ways.  For example, if we have a decla

Re: Named record pattern

2022-05-31 Thread Brian Goetz
Erm... I actually thought that it was your idea to allow the 'final' modifier on patterns. This change was introduced in Java 16 (when patterns for instanceof were finalized). Here's the initial e-mail from you (item 2): https://mail.openjdk.java.net/pipermail/amber-spec-experts/2020-August/00

Re: Named record pattern

2022-05-31 Thread Tagir Valeev
Hello! On Mon, May 30, 2022 at 6:54 PM Brian Goetz wrote: > I must admit to being very surprised that you can do this at all! I > don't recall discussion on this, and had you asked me, I would have said > that `final` has no place in type-test patterns. Yet, I just tried it > with jshell and it

Re: Named record pattern

2022-05-30 Thread Brian Goetz
Thank you so much for catching this. On 5/30/2022 12:36 PM, Tagir Valeev wrote: Hello! I'm reading the spec draft near "14.30.1 Kinds of Patterns" [1] and I wonder how the variable declared as named record pattern differs from the variable declared in the type test pattern

Named record pattern

2022-05-30 Thread Tagir Valeev
Hello! I'm reading the spec draft near "14.30.1 Kinds of Patterns" [1] and I wonder how the variable declared as named record pattern differs from the variable declared in the type test pattern Assuming record Point(int x, int y) {} One can use a pattern like obj instanceof P