[sealed] Use 'open' instead of 'non-sealed'?

Remi Forax forax at univ-mlv.fr
Tue Jan 26 12:25:56 UTC 2021


----- Mail original -----
> De: "Tagir Valeev" <amaembo at gmail.com>
> À: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Mardi 26 Janvier 2021 10:36:18
> Objet: [sealed] Use 'open' instead of 'non-sealed'?

> Hello!
> 
> The 'non-sealed' keyword looks not very java-ish. It adds cognitive
> load, especially to non-native speakers, as it includes the negation
> inside. 

not a problem in French, "no" is "non" in French,
we have more trouble with NaN also meaning no :) 

> Also, it complicates tooling implementation (in particular,
> lexing Java programs). Probably some of us want to move forward the
> hyphenated keywords proposal and need a guinea pig to experiment with,
> but this doesn't seem enough reason to justify its use.
> 
> I suggest using the 'open' contextual keyword instead. The 'open'
> class/interface means that it can be inherited without any
> restriction. 'open', 'sealed', and 'final' keywords are mutually
> exclusive. Any class/interface is either 'open', or 'sealed', or
> 'final', no other option. The classes that don't directly
> extend/implement sealed classes/interfaces are implicitly 'open'
> (though it's possible to redundantly specify the 'open' keyword). The
> classes that extend/implement sealed class/interface must specify
> open/sealed/final explicitly.

so same semantics as non-sealed, just the name of the keyword that changes.

I see two reasons to not use open, non-sealed has the nice property of not having to learn two keywords/semantics and open is the context of a module has a semantics which is quite different from if we would use open instead of non-sealed.

> 
> What do you think?
> 
> With best regards,
> Tagir Valeev.

Rémi


More information about the amber-spec-experts mailing list