Yield as contextual keyword

Tagir Valeev amaembo at gmail.com
Sat May 25 06:05:15 UTC 2019


On Sat, May 25, 2019 at 4:44 AM Alex Buckley <alex.buckley at oracle.com> wrote:
> On the other hand, the space after `:` is sometimes desirous of an
> expression, so tokenize `yield` as a identifier: (and it might be the
> name of a local variable, so no way to qualify)
> - `for (String s : yield . f) ...`
> - `m(a ? yield . f : yield . g)`

Well to me it seems that `:` is no more special here than other listed
tokens (probably except `}`). E.g.:

- After `)`: ((Foo)yield).bar();
- After `{`: Object[] arr = {yield};
- After `;`: for(int i=0; i<10; yield(i++)) {}

`yield` keyword is always preceded by one of X, Y, Z tokens doesn't
mean that any `yield` character sequence which follows X, Y or Z
tokens is necessarily a keyword. Only where YieldStatement production
is expected we treat it as a keyword.

Btw `yield` keyword can also appear after `else` token: if(foo) yield
bar; else yield baz;

With best regards,
Tagir Valeev.

More information about the amber-spec-experts mailing list