break seen as a C archaism

Guy Steele guy.steele at oracle.com
Thu Mar 15 19:28:04 UTC 2018


> On Mar 15, 2018, at 3:40 PM, Remi Forax <forax at univ-mlv.fr> wrote:
> 
> 
> 
> ----- Mail original -----
>> De: "Guy Steele" <guy.steele at oracle.com>
>> À: "mark" <mark at io7m.com>
>> Cc: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
>> Envoyé: Jeudi 15 Mars 2018 20:18:34
>> Objet: Re: break seen as a C archaism
> 
>>> On Mar 15, 2018, at 3:06 PM, Mark Raynsford <mark at io7m.com> wrote:
>>> 
>>> On 2018-03-15T14:50:45 -0400
>>> Brian Goetz <brian.goetz at oracle.com> wrote:
>>>> 
>>>>> If you are reconsidering options, reconsider "yield", meaning
>>>>>  "break current context with this value".
>>>> 
>>>> Still feeling a little burned by first time we floated this, but willing
>>>> to try another run up the flagpole....
>>> 
>>> Silly idea, but... *puts on fireproof suit*:
>>> 
>>> "finally x;"
>> 
>> Interestingly, the keywords `try` and `catch` and `finally` currently must each
>> be followed by a block, so there is indeed syntactic space to use each one with
>> a following expression instead.
>> 
>> Which only suggests that . . . *puts on fireproof suit and then climbs into a
>> concrete bunker and slams the door*:
>> 
>>  “try x;”
>> 
>> would be shorter and no sillier.
>> 
>> —Guy
> 
> It seams too close to the try-with-resources.
> 
> compare
>  try (resource) -> { };  // a try that break/return a lambda
> with
>  try (resource) { }  // a try-with-resources
> 
> Rémi

Indeed.  Mine was not a serious suggestion.  I agree with John Rose’s analysis: “break x;” really does seem to be the best point in the design space, especially since you can use “->” to hide it 98% of the time.

	"But I was thinking of a plan
	To dye one's whiskers green,
	And always use so large a fan
	That they could not be seen.”

		—Lewis Carroll




More information about the amber-spec-experts mailing list