Call for bikeshed -- break replacement in expression switch

John Rose john.r.rose at oracle.com
Thu May 16 20:46:42 UTC 2019


On May 16, 2019, at 1:34 PM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> 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".

The tricky bit with that is the user experience.  What if the
user needs a parenthesized expression:

yield ("answer is "+x).trim();

There are some sharp edges here.

Oh, look, it's a workaround bikeshed:

yield false? 0: ("answer is "+x).trim();
yield (String)("answer is "+x);
yield new String[]{ "answer is "+x }[0];
yield Arrays.asList("answer is "+x).get(0);
yield Objects.id("answer is "+x);

And my own little favorite, a bespoke
use of arrow:

yield -> ("answer is "+x);

Maybe then also:

`yield -> { block of stuff to do before I go; YepDone: yield s; };`

— John



More information about the amber-spec-observers mailing list