Draft JEP: Keyword Management for the Java Language
daniel.smith at oracle.com
Fri May 3 23:44:16 UTC 2019
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
To supplement the discussion (and you've probably nodded in this direction enough already in the document), I'll note that I think there's still a lot of room for re-using the "type identifier" concept for certain keyword needs, such as modifiers.
How I'd rephrase your notes:
"various linguistic heroics, such as reclassifying the identifier var when it appears as a type name"
"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.)
> On Apr 30, 2019, at 6:50 PM, Alex Buckley <alex.buckley at oracle.com> wrote:
> Evolving the Java language often means new keywords for new features, but new keywords risk breaking existing programs. In the Project Amber expert group, Brian Goetz suggested a technique for generating new keywords that balances compatibility and readability -- _hyphenated keywords_ -- and there is already a language feature raring to use it (JEP 354, Switch Expressions).
> We have now produced an Informational JEP to record the intent and detail of hyphenated keywords, for Feature JEPs may rely on. It also captures a policy for managing (that is, stewarding) Java's keywords more broadly. Your comments are welcome.
More information about the jdk-dev