On 16/05/2019 21:04, Brian Goetz wrote:
The notion of “reserved word” is insufficiently precise. More
precisely, yield is a _reserved type identifier_, like `var`. That
means that you cannot have a class called `yield`, but you can have
local variables, or methods, or fields, or type variables, with that
name.
Yep - but it's also different from 'var' in the sense that 'var' never
had to fight with ambiguities with method names because it only applied
to the 'type' part of a variable declaration, which is either a
(possibly qualified) identifier (possibly followed by '<'). Parenthesis
were never allowed where 'var' as a type was expected.
For yield Eamon is right - there's a new kind of ambiguity.
On the other hand is a trivial one to resolve, given what we're
discussing now is something like
"yields" EXPRESSION
so, as soon as the compiler sees a "(" it will say: "ok, that's not a
new yield statement".
Maurizio
See
https://openjdk.java.net/jeps/8223002
for further guidance on the fine degrees of shading between keywords,
context-sensitive keywords, reserved identifiers, and reserved type
names.
On May 16, 2019, at 3:56 PM, Éamonn McManus <emcma...@google.com
<mailto:emcma...@google.com>> wrote:
"yield" isn't a reserved word, is it? Doesn't that mean that
`yield(5);` is ambiguous?