Re: [External] : Re: Possible refinement for sealed classes

2021-04-01 Thread forax
- Mail original - > De: "Brian Goetz" > À: "Remi Forax" > Cc: "amber-spec-experts" > Envoyé: Jeudi 1 Avril 2021 22:32:23 > Objet: Re: [External] : Re: Possible refinement for sealed classes >> By example, a type WithCheese may mak

Re: [External] : Re: Possible refinement for sealed classes

2021-04-01 Thread Brian Goetz
By example, a type WithCheese may make little sense. Anyway, if WithCheese only makes sense for a Sandwich, nesting WithCheese inside Sandwich is the way to go. This doesn't help unless the *whole* hierarchy is nested in the same file.  Otherwise you have to have an explicit permits clause

Re: [External] : Re: Possible refinement for sealed classes

2021-04-01 Thread forax
> De: "Brian Goetz" > À: "Remi Forax" > Cc: "amber-spec-experts" > Envoyé: Jeudi 1 Avril 2021 16:27:55 > Objet: Re: [External] : Re: Possible refinement for sealed classes >>> Essentially, I want to put the `permits` list on Sandwich, and

Re: Possible refinement for sealed classes

2021-04-01 Thread Guy Steele
> On Apr 1, 2021, at 9:23 AM, Brian Goetz wrote: > > ... > Without trying to paint the bikeshed, this is a pretty simple extension to > sealing: > > sealed interface WithCheese __refines Sandwich { } > > This says that WithCheese is sealed to either classes that extend Sandwich, > or ot

Re: [External] : Re: Possible refinement for sealed classes

2021-04-01 Thread Brian Goetz
Essentially, I want to put the `permits` list on Sandwich, and have `WithCheese` and friends delegate their permits to `Sandwich`, rather than having each interface enumerate their subtypes. I'm not sure to understand why this case is special enough to get a special way of de

Re: Possible refinement for sealed classes

2021-04-01 Thread Remi Forax
> De: "Brian Goetz" > À: "amber-spec-experts" > Envoyé: Jeudi 1 Avril 2021 15:23:28 > Objet: Possible refinement for sealed classes > Been working with sealed classes a lot lately, and have run into a pattern > that > we might want to consider supportin

Re: [External] : Re: Possible refinement for sealed classes

2021-04-01 Thread Brian Goetz
It depends how far we want to take this.  If we limit this to sealed classes, we can just do as you say, copy the permitted subclasses of Sandwich into the permitted subclasses of WithCheese, possibly filtering for whether with Cheese is actually a supertype.  (If we want to capture the notion

Re: Possible refinement for sealed classes

2021-04-01 Thread Dan Heidinga
Seems like a reasonable proposal. > sealed interface WithCheese __refines Sandwich { } Would `_refines` operate at compile time with javac copy/pasting the sealed list from Sandwich into WithCheese? An alternative is some new classfile info to tell the VM to do the copy/paste at classload. Both

Possible refinement for sealed classes

2021-04-01 Thread Brian Goetz
Been working with sealed classes a lot lately, and have run into a pattern that we might want to consider supporting more directly, which is interfaces that exist solely to refine a sealed class or interface. Suppose we have:     sealed abstract class Sandwich { }     interface WithCheese { }