Guards
Guy Steele
guy.steele at oracle.com
Fri Mar 5 23:39:47 UTC 2021
> On Mar 5, 2021, at 6:32 PM, John Rose <john.r.rose at oracle.com> wrote:
>
> On Mar 5, 2021, at 3:11 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
>>
>>
>> Or:
>>
>> case &&e:
>
> Yes, I was reticent about that, but perhaps
> unary “&&” is a reasonable marker for
> “go into expression land”. It could also
> help to mark in-args for deconstructor
> methods.
Ah, you have put your finger on what bothers me about using the specific symbol `&&` in this specific way: it looks like a unary operator, and unary operators bind tight.
case && x > 0:
looks like it ought to mean
case ((&& x) > 0):
Now,
case var _ && x > 0:
clearly does the job, and the abbreviated form
case _ && x > 0:
I could get behind. But even that is beginning to be a lot of noise to introduce the guard.
Maybe we are just trying too hard. Maybe we should use && to introduce guards, but
case var _ && x > 0:
can be abbreviated as
when x > 0:
?
More information about the amber-spec-experts
mailing list