Draft JEP: Keyword Management for the Java Language
alex.buckley at oracle.com
Sat May 4 00:31:43 UTC 2019
On 5/3/2019 4:44 PM, Dan Smith wrote:
> Clarification on the asides about `var`:
> "various linguistic heroics, such as reclassifying the identifier var as a type name but only in variable declarations"
> "a sequence of Java letters that is always tokenized as an identifier for which special provision is made in certain contexts (e.g., var, a type identifier in Java 10, also known as a reserved type name)."
> Here's the model:
> - `var` is an identifier
> - A *type identifier* is an identifier that can be used to name a type—a subset of all identifiers
> - `var` is *not* a type identifier
> - The identifier `var` is explicitly matched by the grammar rule LocalVariableType, and in that case given special meaning
Oops, yes, the JEP was wrong to say "var, a type identifier in Java 10".
> How I'd rephrase your notes:
> "various linguistic heroics, such as reclassifying the identifier var when it appears as a type name"
The phrasing "such as X _but only in ..._, or Y _but only in ..._" is
pedagogical -- it gets a point across in the high-level motivation.
However, I agree that "reclassifying" is too strong for `var` -- it is
always and everywhere an identifier -- so I have changed it to "such as
treating the identifier `var` as a type name _but only in local variable
> "a sequence of Java letters that is always tokenized as an identifier for which special provision is made in certain contexts (e.g., var, a reserved type name in Java 10)."
> (I don't know if the term "reserved type name" is formally defined somewhere, but it seems like an appropriate description.)
"reserved type name" isn't a JLS term, but I have no quarrel with it
being the primary label for `var` in the JEP. I linked to the special
syntactic treatment of `var` in 14.4 and the special semantic treatment
More information about the jdk-dev