Yield as contextual keyword (was: Call for bikeshed -- break replacement in expression switch)
John Rose
john.r.rose at oracle.com
Mon May 20 20:00:43 UTC 2019
On May 20, 2019, at 12:51 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
>
> The cost-benefit analysis rests on the assumption that this will bite exceedingly rarely, and when it does, the workaround will be clear and easy.
OK, so let's road-test "yield".
While "break: x" is syntactically safer than "yield x", I buy
your argument. And "yield x" is easier to explain to users.
We all know why ":" is necessary in "break: x" but users
will need explanations about the colon where "yield x"
will just work for them.
There's always a trade-off between precision and
concision. Concise formulations are inherently
ambiguous, just because there are a limited number
of length-N strings and each can be given only one
semantic pigeonhole. Adding a new keyword
lets us occupy new pigeonholes with the same
number of tokens.
So, while "break: x" would please me as a syntax
geek, "yield x" (if it really works) will please me
as a user. We should try it if we think we can
make it work.
— John
More information about the amber-spec-experts
mailing list