<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>Hi Peter,<br data-mce-bogus="1"></div><div>I think this have been ruled out but Brian saying that we do not want to add a block that ends with an expression in Java.<br></div><div>And i think we can use parenthesis to avoid to re-interpret what a <br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div> int value = do(<br data-mce-bogus="1"></div><div> int x = foo(); <br data-mce-bogus="1"></div><div> break x * x;<br data-mce-bogus="1"></div><div> );<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>If we go in that direction, i think i prefer the comprehension-like syntax where you put the expression giving the result first and then the block that calculates the value,<br data-mce-bogus="1"></div><div>it has the advantage of being an expression, so it fits with the arrow syntax <br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div> switch(value) {<br data-mce-bogus="1"></div><div> case 0 -> 0<br data-mce-bogus="1"></div><div> case 1 -> x * x with { x = foo(); } <br data-mce-bogus="1"></div><div> }<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>regards,<br data-mce-bogus="1"></div><div>Rémi<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De: </b>"Peter Levart" <peter.levart@gmail.com><br><b>À: </b>"John Rose" <john.r.rose@oracle.com>, "Maurizio Cimadamore" <maurizio.cimadamore@oracle.com><br><b>Cc: </b>"amber-spec-experts" <amber-spec-experts@openjdk.java.net><br><b>Envoyé: </b>Vendredi 16 Mars 2018 10:39:05<br><b>Objet: </b>Re: break seen as a C archaism<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">
Expanding on do...<br>
<br>
<div class="moz-cite-prefix">On 03/16/18 09:50, Peter Levart wrote:<br>
</div>
<blockquote cite="mid:c90e1ca9-26b2-42fb-2bbd-3ecb817a7363@gmail.com">
And if "while (false)" could be optional, we get:<br>
</blockquote>
<br>
Or better yet, make "while (true)" optional even in statement do, so
we can finally get away with some more boilerplate:<br>
<br>
for (;;) {<br>
}<br>
<br>
or<br>
<br>
while (true) {<br>
}<br>
<br>
and simply do:<br>
<br>
do {<br>
}<br>
<br>
For e-do, the choice of default "while (true)" is fine, because it
aligns with the fact that there has to be a break <value>
somewhere to exit it anyway because it has to yield a result. But
there will be some danger that a programmer codes an infinite loop
by mistake.<br>
<br>
<br>
<blockquote cite="mid:c90e1ca9-26b2-42fb-2bbd-3ecb817a7363@gmail.com">
<br>
doSomething(<br>
par1,<br>
do {<br>
// compute result...<br>
break resut;<br>
},<br>
par3<br>
);<br>
<br>
</blockquote>
<br>
Expanding on e-do... It could be a building block for e-switch. Remi
is advocating for expression-only case(s) in e-switch. Combined with
e-do, we could write:<br>
<br>
int y = switch (x) {<br>
case 1 -> 2;<br>
case 2 -> 3;<br>
case 3 -> do {<br>
r = ...;<br>
break r;<br>
};<br>
};<br>
<br>
What we loose here is fallthrough. And we still have "break" here
too.<br>
<br>
It's unfortunate that we couldn't find a way to have an e-{block} of
a kind when lambdas have been conceived. That way we could get away
with expression-only lambdas and expression-only cases in e-switch
using the same building block. But I guess the statement lambda has
its weight with its "return" sticking out and reminding us about the
scope.<br>
<br>
Regards, Peter<br>
<br><br></blockquote></div></div></body></html>