break seen as a C archaism

forax at forax at
Mon Mar 12 23:23:11 UTC 2018

----- Mail original -----
> De: "Brian Goetz" <brian.goetz at>
> À: "Victor Nazarov" <asviraspossible at>, "Amber Expert Group Observers" <amber-spec-observers at>
> Cc: "Remi Forax" <forax at>
> Envoyé: Lundi 12 Mars 2018 20:38:15
> Objet: Re: break seen as a C archaism

>> Most problematic for me is that everywhere in Java block syntax (curly
>> braces) is used to switch (no pun intendent) between single expression
>> / statement and multiple statement variant. But for switch expressions
>> colon and arrow is used instead... This seems verry irritating seens
>> whole language managed to use block syntax everywhere else before...
> But, the whole point is, we *didn't* use block syntax everywhere before
> -- specifically not in switch.  The treatment of blocks in switch has
> always been an irregularity.  And the proposal about switch is in
> keeping with how switch has always worked.
> Is this the only way we could play it?  Surely not.  We could try to
> "fix" switch -- as many have suggested we do.  And doing so will create
> obvious seams.  We could make a new construct, "match", that is like
> switch, but not.  Then we'll have two similar, but different, ways to do
> the same thing.  So my preference has been, to the extent was can extend
> switch in a manner consistent with its heritage, let's do that.
> Would we do this if were designing a new language from scratch?  Of
> course not.  But that's not what we're doing here.

I think having another syntax for the block syntax of an expression switch makes little sense,
we still have two possibilities, adding 'break value', or saying that we do not support block syntax in case of a switch expression.
I'm still not convinced which one is the better.

There is an argument against adding 'break value' (at least yet), now that we have rolling releases, we have the choice of introducing the expression switch with no support for the block syntax and see if it's not enough (we have no block syntax for ?: and most IDEs are able to move from if/else to ?: and vice versa).


More information about the amber-spec-observers mailing list