Re: [External] : Re: Remainder in pattern matching

2022-04-07 Thread Alan Malloy
Yes, this clears up my concerns. On Fri, Apr 1, 2022 at 6:56 AM Brian Goetz wrote: > > It seems pretty hard to land anywhere other than where you've landed, for > most of this. I have the same sort of question as Dan: do we really want to > wrap exceptions thrown by other patterns? You say we wa

Re: [External] : Re: Remainder in pattern matching

2022-04-01 Thread Brian Goetz
It seems pretty hard to land anywhere other than where you've landed, for most of this. I have the same sort of question as Dan: do we really want to wrap exceptions thrown by other patterns? You say we want to discourage patterns from throwing at all, and that's a lovely dream, but the behav

Re: Remainder in pattern matching

2022-03-31 Thread Alan Malloy
It seems pretty hard to land anywhere other than where you've landed, for most of this. I have the same sort of question as Dan: do we really want to wrap exceptions thrown by other patterns? You say we want to discourage patterns from throwing at all, and that's a lovely dream, but the behavior of

Re: [External] : Re: Remainder in pattern matching

2022-03-31 Thread Brian Goetz
Here's some candidate spec text for MatchException: Prototype spec for MatchException ( a preview API class ). Thrown to indicate an unexpected failure in pattern matching. MatchException may be thrown when an exhaustive pattern matching language construct (such as a switch expression) encoun

Re: [External] : Re: Remainder in pattern matching

2022-03-30 Thread Remi Forax
- Original Message - > From: "Dan Heidinga" > To: "Brian Goetz" > Cc: "amber-spec-experts" > Sent: Wednesday, March 30, 2022 8:43:42 PM > Subject: Re: [External] : Re: Remainder in pattern matching > On Wed, Mar 30, 2022 at 2:38 PM B

Re: [External] : Re: Remainder in pattern matching

2022-03-30 Thread Brian Goetz
Yes, and this is a special case of a more general thing -- that while pattern declarations may have a lot in common with methods, they are not "just methods with multiple return" (e.g., they have a different set of characteristics at the declaration, they are intrinsically conditional, they are

Re: [External] : Re: Remainder in pattern matching

2022-03-30 Thread forax
> From: "Brian Goetz" > To: "Remi Forax" > Cc: "amber-spec-experts" > Sent: Wednesday, March 30, 2022 8:35:17 PM > Subject: Re: [External] : Re: Remainder in pattern matching >> It seems that what you are saying is that you think an Excep

Re: [External] : Re: Remainder in pattern matching

2022-03-30 Thread Dan Heidinga
On Wed, Mar 30, 2022 at 2:38 PM Brian Goetz wrote: > > Another way to think about this is: > > - If any of the code that the user actually wrote (the RHS of case clauses, > or guards on case labels) throws, then the switch throws that > - If any of the machinery of the switch dispatch throws, i

Re: [External] : Re: Remainder in pattern matching

2022-03-30 Thread Remi Forax
- Original Message - > From: "Brian Goetz" > To: "Dan Heidinga" > Cc: "amber-spec-experts" > Sent: Wednesday, March 30, 2022 8:26:53 PM > Subject: Re: [External] : Re: Remainder in pattern matching [...] > > One thing wrapp

Re: [External] : Re: Remainder in pattern matching

2022-03-30 Thread Brian Goetz
Another way to think about this is:  - If any of the code that the user actually wrote (the RHS of case clauses, or guards on case labels) throws, then the switch throws that  - If any of the machinery of the switch dispatch throws, it throws MatchException. On 3/30/2022 2:12 PM, Dan Heidinga

Re: [External] : Re: Remainder in pattern matching

2022-03-30 Thread Brian Goetz
It seems that what you are saying is that you think an Exception is better than an Error. Not exactly; what I'm saying is that the attempt to separate stray nulls from separate compilation issues here seems like a heroic effort for low value, and I'd rather have one channel for "exhaustive

Re: [External] : Re: Remainder in pattern matching

2022-03-30 Thread forax
> From: "Brian Goetz" > To: "Remi Forax" > Cc: "amber-spec-experts" > Sent: Wednesday, March 30, 2022 6:32:15 PM > Subject: Re: [External] : Re: Remainder in pattern matching >> For when the static world and the dynamic world disagree,

Re: [External] : Re: Remainder in pattern matching

2022-03-30 Thread Brian Goetz
It's a little like calling a method, but a little not like it too. For example, when you match on a record pattern:     case Point(var x, var y): ... what may happen is *either* you will invoke a user-written deconstructor pattern, *or* we will test if you are a Point with `instanceof`, and t

Re: Remainder in pattern matching

2022-03-30 Thread Dan Heidinga
The rules regarding NPE, ICCE and MatchException look reasonable to me. > As a separate but not-separate exception problem, we have to deal with at > least two additional sources of exceptions: > > - A dtor / record acessor may throw an arbitrary exception in the course of > evaluating whether

Re: [External] : Re: Remainder in pattern matching

2022-03-30 Thread Brian Goetz
For when the static world and the dynamic world disagree, i think your analysis has miss an important question, switching on an enum throw an ICCE very late when we discover an unknown value, but in the case of a sealed type, Actually, I thought about that quite a bit before proposing this

Re: Remainder in pattern matching

2022-03-30 Thread Remi Forax
> From: "Brian Goetz" > To: "amber-spec-experts" > Sent: Wednesday, March 30, 2022 4:40:28 PM > Subject: Remainder in pattern matching > We should have wrapped this up a while ago, so I apologize for the late > notice, > but we really have to wrap u

Remainder in pattern matching

2022-03-30 Thread Brian Goetz
We should have wrapped this up a while ago, so I apologize for the late notice, but we really have to wrap up exceptions thrown from pattern contexts (today, switch) when an exhaustive context encounters a remainder.  I think there's really one one sane choice, and the only thing to discuss is