> On 12 Mar 2021, at 11:02, Remi Forax <fo...@univ-mlv.fr> wrote: > > ----- Mail original ----- >> De: "Gavin Bierman" <gavin.bier...@oracle.com> >> À: "John Rose" <john.r.r...@oracle.com> >> Cc: "amber-spec-experts" <amber-spec-experts@openjdk.java.net> >> Envoyé: Vendredi 12 Mars 2021 11:11:46 >> Objet: Re: Guards redux > >> Thanks everyone for the discussion. I have updated the JEP: >> >> http://openjdk.java.net/jeps/8213076 >> >> It proposes *guarded patterns* of the form `p&&e`, as well as parenthesized >> patterns, written `(p)`. > > > Hi Gavin, > nice, i find this version more appealing.
Yay! > In the first example that shows && as a guard, the example uses parenthesis > which is my opinion should be removed > case Triangle t && (t.calculateArea() > 100) -> > System.out.println("Large Triangle"); > > if i read the grammar correctly, those parenthesis around the boolean > expression are unnecessary > case Triangle t && t.calculateArea() > 100 -> They are unnecessary, but this example comes before the grammar, so I didn’t want anyone to get confused. > > it will be more inline with the example above in the text that is using 'when' > case Triangle t when t.calculateArea() > 100 -> > > > Otherwise, in the document, the words "->-style" and ":-style" are hard to > parse, i think array-style and colon-style are better terms. I’ll take a look. > In the section "Dominance of pattern label", > It's not clear to me if there is a dominance in between expressions, > by example, can we have the following cases in that order ? > > case Foo(var a, var b) && a == 3: > case Foo(var a, var b) && a == 3 && b == 4: > > for me the answer is yes, the dominance is computed on patterns only, not on > expressions. I agree. I don’t think trying to calculate dominance between expressions is viable. Thanks Rémi! Gavin