Re: [External] : Re: Fwd: Two new draft pattern matching JEPs

2021-03-09 Thread John Rose
On Mar 9, 2021, at 12:23 PM, John Rose wrote: > > If switch refactors > to an if-chain, why then continue-switch would refactor to > continue-if, which turns out to branch to the next “else”, > if any. A bit more detail in case that was cryptic: switch (obj) { ... case P &&guard G: … … } <=ref

Re: [External] : Re: Fwd: Two new draft pattern matching JEPs

2021-03-09 Thread John Rose
On Mar 5, 2021, at 8:29 AM, Brian Goetz wrote: > >> >> The one objection I still have to grobble is one I've raised before: it >> makes it hard to imagine ever representing disjunctions as guards. I always >> bring up stuff like >> >> switch (people) { >> case Pair(Person(String name1, int

Re: [External] : Re: Fwd: Two new draft pattern matching JEPs

2021-03-05 Thread Brian Goetz
The one objection I still have to grobble is one I've raised before: it makes it hard to imagine ever representing disjunctions as guards. I always bring up stuff like switch (people) {   case Pair(Person(String name1, int age1), Person(String name2, int age2))     | age1 > age2 -> name1

Re: [External] : Re: Fwd: Two new draft pattern matching JEPs

2021-03-04 Thread Brian Goetz
Thanks Alan, this kind of confirms what I was thinking. I agree that while it might seem "silly" that we react to `true(x)` as being contrary to our expectations of truth, it is real, and after asking a few other sensible people who can sit on their bikeshed-impulses, seems fairly common.  So

Re: Fwd: Two new draft pattern matching JEPs

2021-03-04 Thread Alan Malloy
I have certainly experienced a double take when seeing true(expr). I can step back and recognize that it's just some arbitrary syntactical choice, and true(x) is evocative of the question "is x true?", but at first glance it is not appealing. Repurposing a language keyword in this way is surprising

Re: Fwd: Two new draft pattern matching JEPs

2021-03-04 Thread Brian Goetz
Lots of people (Remi here, VictorN on a-comments, StephenC on a-dev) are complaining about true/false patterns, but my take is that we've not really gotten to the real objections; instead, I'm seeing mostly post-hoc rationalizations that try and capture the objections (understandable), but I do

Fwd: Two new draft pattern matching JEPs

2021-03-04 Thread Brian Goetz
Received on the -comments list. Analysis from the legislative analyst: This comment amounts to "Well, if you could eventually write the true/false patterns as declared patterns which ignore their target, then just do declared patterns now, and just make them declared patterns."  (Which is exa