Updated JEP: nestmates

John Rose john.r.rose at oracle.com
Fri Apr 14 20:17:08 UTC 2017

On Apr 13, 2017, at 2:44 PM, David Holmes <david.holmes at oracle.com> wrote:
> D is not a nest! D is a type that may be in a nest. "nest of D" is perfectly correct. We could rephrase to "of the same nest as D".

Hmm, this is tricky to express unambiguously in English.

There are several things going on:  A nest (viewed as a single "thing"), a set of all
classes "in the nest", the reverse relation of each class "in the nest" to the nest it is in,
and finally the precursor relations, defined exactly by the attributes, from which the
nest emerges:  nest-top, nest-members.

Conflating the precursor relations with the main relation will cause endless confusion
if we are not careful.

As you point out, David, it helps to distinguish the "nest" from the "nest top".

In pseudocode:

// main bidirectional relation:
datatype Nest: SetOf(Class)
NestMembers: (Nest) -> SetOf(Class)
IsInNest: (Class, Nest) -> boolean

// utility:
IsInSameNestAs: (Class, Class) -> boolean

// precursor relations carried directly by attributes:
NestTop: Class -> Optional(Class)
NestMembers: Class -> Optional(ListOf(Class))

— John

P.S. This relates back to reflection:

To me it is a coin-flip whether the JDK Core Reflection API should reify
the derived relation (with a Class.Nest object) or the precursor relations.
The "style" of Class APIs is to postprocess the internal precursor data
into a franken-something that looks like source structure.  But I'm leaning
towards reifying only the simpler precursor relations, in this case.

More information about the valhalla-dev mailing list