Re: [External] : Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-28 Thread Brian Goetz
You can say you only change the semantics of switch not the semantics of pattern matching, but the idea that you can separate the two is confusing. From a mathematical point of view, it is quite clear.  We define a `x matches P` relation.  In this relation, `Object o` matches all values of

Re: [External] : Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-28 Thread forax
> From: "Brian Goetz" > To: "Remi Forax" > Cc: "Tagir Valeev" , "amber-spec-experts" > > Sent: Thursday, January 27, 2022 4:41:27 PM > Subject: Re: [External] : Re: Treatment of total patterns (was: Reviewing > feedback on patterns in switch) >> In that case, i prefer the current semantics

Re: [External] : Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-27 Thread Brian Goetz
In that case, i prefer the current semantics because it's the same if a pattern is a top-level or not. I wish people could keep these things straight. We’re not talking about changing the semantics of how pattern matching works, which patterns match what, what nesting means, etc. We’re

Re: [External] : Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-27 Thread forax
> From: "Brian Goetz" > To: "Remi Forax" > Cc: "Tagir Valeev" , "amber-spec-experts" > > Sent: Wednesday, January 26, 2022 3:08:39 PM > Subject: Re: [External] : Re: Treatment of total patterns (was: Reviewing > feedback on patterns in switch) > I don’t think its helpful to try and reopen

Re: [External] : Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-26 Thread Brian Goetz
I don’t think its helpful to try and reopen these old and settled issues. I get that you think null should have a larger syntactic presence in the language, and you’ve made those points plenty of times, but we’re not reopening whether `Object o` is total, or whether `var` is more than type

Re: [External] : Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-26 Thread forax
> From: "Brian Goetz" > To: "Remi Forax" > Cc: "Tagir Valeev" , "amber-spec-experts" > > Sent: Wednesday, January 26, 2022 1:47:38 PM > Subject: Re: [External] : Re: Treatment of total patterns (was: Reviewing > feedback on patterns in switch) > Heh, you are incrementally rediscovering exactly

Re: [External] : Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-26 Thread Brian Goetz
Heh, you are incrementally rediscovering exactly why we chose the original “total is total” rule; of all the possible treatments, it is the most logically consistent. Welcome. In this case, however, switches must be total. So here, either D is total (perhaps with remainder), or B/C/D cover

Re: [External] : Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-26 Thread Brian Goetz
> I strongly support this change. > > In my experience, it's much more important to have automatic > refactorings between switch and chains of 'if' than between nested and > flat switches. Of course, this might be partially because we *have* chains of if else now, but no switches on nested

Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-25 Thread Remi Forax
- Original Message - > From: "Tagir Valeev" > To: "Brian Goetz" > Cc: "amber-spec-experts" > Sent: Wednesday, January 26, 2022 5:20:24 AM > Subject: Re: Treatment of total patterns (was: Reviewing feedback on patterns > in switch) >> Null is only matched by a switch case that includes

Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-25 Thread Tagir Valeev
> Null is only matched by a switch case that includes `case null`. Switches > with no `case null` are treated as if they have a `case null: throw NPE`. > This means that `case Object o` doesn’t match null; only `case null, Object > o` does. > Total patterns are re-allowed in instanceof

Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-25 Thread Remi Forax
> From: "Brian Goetz" > To: "amber-spec-experts" > Sent: Tuesday, January 25, 2022 8:47:09 PM > Subject: Treatment of total patterns (was: Reviewing feedback on patterns in > switch) >> 1. Treatment of total patterns in switch / instanceof > The handling of totality has been a long and painful

Treatment of total patterns (was: Reviewing feedback on patterns in switch)

2022-01-25 Thread Brian Goetz
1. Treatment of total patterns in switch / instanceof The handling of totality has been a long and painful discussion, trying to balance between where we want this feature to land in the long term, and people’s existing mental models of what switch and instanceof are supposed to do. Because