Java 10 comes with the new Local Variable Type Inference. The token var
can be used to reduce the boilerplate required when declaring a variable. e.g.
var s = "hello";
According to What type of token is exactly "var" in Java 10? this new token is not a "keyword" but rather is a "reserved type name". As such the word "var" can still be used as a variable name which maintains backwards compatibility with existing code.
var var = "you can do this";
When the "module" feature was introduced in Java 9 the type of this new token (along with its 9 other related tokens) were called a "restricted keywords". Which is to say they were only considered keywords under certain context specific restrictions. e.g. you can still have variables called module.
When new language features were added to C++ in such a way that they did not clobber existing user defined symbols they were called "context-sensitive keywords".
Is there a conceptual difference between the new "reserved type name" var
token in Java 10 and a "context-sensitive keyword" or "restricted keyword". Which is to say isn't the new var
token really just a keyword under certain context specific restrictions. If that is the case why wasn't it simply added to the list of "restricted keywords"?
To add to my confusion further the current draft version of the JLS says that:
The character sequence var is generally treated as an identifier, but in certain special cases acts as if it were a keyword instead.
That definition certainly sounds like a "restricted keyword".