[External] : Re: Guards redux
gavin.bierman at oracle.com
Fri Mar 12 11:36:19 UTC 2021
> On 12 Mar 2021, at 11:02, Remi Forax <forax at univ-mlv.fr> wrote:
> ----- Mail original -----
>> De: "Gavin Bierman" <gavin.bierman at oracle.com>
>> À: "John Rose" <john.r.rose at oracle.com>
>> Cc: "amber-spec-experts" <amber-spec-experts at 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:
>> 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.
> 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.
More information about the amber-spec-experts