Draft Spec for Second Preview of Flexible Constructor Bodies (JEP 482)
Stephan Herrmann
stephan.herrmann at berlin.de
Sun Jun 9 08:57:27 UTC 2024
Am 08.06.24 um 00:48 schrieb Archie Cobbs:
> I think one thing we could do to help lower the confusion level is come up with
> some less ambiguous "enclosing" terminology.
sounds good to me
> The compiler's "NOOUTERTHIS" doesn't help.
I have no idea what "NOOUTERTHIS" means in javac.
ecj does not have any such feature and doesn't need it, AFAICS.
> In an ideal world we would all agree to use some standard, non-ambiguous
> terminology, e.g.:
>
> * The phrasing should always be "enclosing instance with respect to D", where
> D is some lexically enclosing class.
> * For a class C, the "enclosing instance of C with respect to D" is /defined/ if:
> o D is a class (not interface, record, enum, etc.)
> o C is nested within D
> o There is no static class (or interface, record, enum, etc.) declaration
> between C and D (including C itself)
> * For a class C, the "enclosing instance of C with respect to D" is
> /accessible/ at some point X in C if:
> o The enclosing instance of C with respect to D is defined
> o X is not in an early construction context of D
> * If C is nested directly within D with no intermediate classes, then
> "enclosing instance of C with respect to D" is also "the immediately
> enclosing instance of C".
Looks good to me, but do we actually need to speak about enclosing instances to
determine legality of expressions? The context dependence already shows up in
sentences like:
- "If the expression name appears in an early construction context of C"
(6.5.6.1)
or
= "It is a compile-time error if a qualified this expression occurs in an
early construction context (8.8.7.1) of the class named by TypeName." (15.8.4).
Anyway, decoupling *definition* of enclosing instances from the question whether
they can be "used" in certain contexts looks like a winner to me (not sure if
"accessible" is the best term here, which otherwise relates to encapsulation).
regards,
Stephan
More information about the amber-spec-experts
mailing list