Call for bikeshed -- break replacement in expression switch

John Rose john.r.rose at
Thu May 16 20:28:58 UTC 2019

On May 16, 2019, at 1:10 PM, Brian Goetz <brian.goetz at> wrote:
> While dodging the arrow, I’ll point out that there is a pleasant ambiguity in the following:
>    x = switch (y) { 
>        case L -> { 
>            foo();
>            yield 7;
>       }
>   };

Yes, it is pleasant, and it applies (potentially)
to lambdas also.

I'm saying it's extra-pleasant (for me) to divide
the story into two chapters:

Chapter 1.  Some constructs have arrows.
They define when the arrow bodies are executed,
and, if the the arrow gets tossed a value, what
is done with that value (method return?
switch result? block result? depends on 
where the arrow is).

Chapter 2.  Every yield matches an innermost
arrow, and every arrow (in a non-void T context)
accepts a yielded value (of type T).

It's pleasant this way because when you get
to Chapter 2, you can forget all the gnarly
context outside the arrow.  Your yield
passes to the innermost arrow, period.
And if there's an arrow in sight (in the
same stack frame) you can yield to it.
Again, period.

More information about the amber-spec-observers mailing list