Re: Enum vs Record vs Sealed types

2020-01-03 Thread Brian Goetz
I agree that all of these pattern matches should be expressible. Under the current plan, we get there (at least) by:  - RED is a constant pattern (well, Color.RED is a constant pattern, anyway.)  - Color(var red, _, _) is a deconstruction pattern, with an explicit deconstructor The feature

Re: Enum vs Record vs Sealed types

2020-01-02 Thread John Rose
On Jan 2, 2020, at 12:52 PM, Remi Forax wrote: > > The other solution, is to wait to have de-constructor, in that case we may > not need a special syntax for enum. Yeah, that’s my first thought on this. Given a deconstructor which we certainly will have, the incremental advantage to

Enum vs Record vs Sealed types

2020-01-02 Thread Remi Forax
Now that the design of Record is mostly stabilized, i think we should talk about the relation between an enum, a record and a sealed type. As we have done with records, we can work backward from the pattern matching switch to see what we need for an enum. So let suppose that like Java2D, we