<div dir="ltr">(Both numbers are supposed to say 0.07%.)<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 10, 2018 at 5:06 PM, Kevin Bourrillion <span dir="ltr"><<a href="mailto:kevinb@google.com" target="_blank">kevinb@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span class=""><div class="gmail_quote">On Thu, May 10, 2018 at 1:04 PM, Brian Goetz <span dir="ltr"><<a href="mailto:brian.goetz@oracle.com" target="_blank">brian.goetz@oracle.com</a>></span> wrote:</div></span><div class="gmail_quote"><span class=""><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<tt>This might not help, but perhaps think of it as a compound
keyword; "break switch" is not "break with an argument of switch",
but a multi-word keyword itself. <br></tt></div></blockquote><div><br></div></span><div>Well, then multi-word keywords are the thing that is novel and should require very strong justification. :-)</div><div><br></div><div>But no. I've gotta disagree with this: If we tell users that they can do "break while", "break for", "continue while", "continue for", and "break switch", no one's mental model will be that those are five different new keywords. There is a very obvious orthogonal separation between (first) what to do and (second) at what scope to do it. That's what I meant by "argument of".</div><span class=""><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><tt>Personally if I saw "break while", I think I'd immediately know
what that means, and might even thank the author for being clear. </tt></div></blockquote><div><br></div></span><div>It's not bad.</div><div><br></div><div>Here's a quick tidbit from our codebase:</div><div><br></div><div>- Labeled break/continue is <i>unfathomably</i> rare -- a rough estimate is 0.07% of all break/continue statements. (<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Just to be clear, no, we don't have any kind of style guide rule about avoiding the use of labels, or static analysis complaining about it, etc.)</span><br></div><div><br></div><div>- And even among this small 0.3%, in virtually every one of them the surrounding loops are of the same kind, so `break <keyword>` would not be applicable. <br></div><div><div class="h5"><div><br></div><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div><div class="m_-7422116221906509852h5">
<div class="m_-7422116221906509852m_-5477076865366105268moz-cite-prefix">On 5/10/2018 3:57 PM, Kevin Bourrillion
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">I'm just going to say that naming a keyword as the
argument of another keyword seems novel and unprecedented for
Java, and as such I think should require pretty strong
justification.
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, May 10, 2018 at 12:12 PM, Guy
Steele <span dir="ltr"><<a href="mailto:guy.steele@oracle.com" target="_blank">guy.steele@oracle.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="m_-7422116221906509852m_-5477076865366105268HOEnZb">
<div class="m_-7422116221906509852m_-5477076865366105268h5"><br>
> On May 10, 2018, at 3:06 PM, Brian Goetz <<a href="mailto:brian.goetz@oracle.com" target="_blank">brian.goetz@oracle.com</a>>
wrote:<br>
> <br>
> <br>
>> I think these are both valid explanations, with
different outcomes, but anyway it's fair to say that it
would be confusing to have the latter perspective and
then try to explain how a value break can get past a
surrounding 'for' loop.<br>
> <br>
> One option is: you can't. While I agree there is
code that one might like to write that is made
cumbersome by this, it's a valid option, and not one
that is utterly terrible.<br>
> <br>
> Another option is to extend the break syntax along
the lines of the proposed continue syntax. Suppose for
every continuable construct x (for, while, switch) we
supported "continue x". So for every breakable
construct y we could support "break y". If a for loop
were enclosed in an expression switch, you could then
say "break switch e". Then<br>
> <br>
>Â Â if (foo)<br>
>Â Â Â Â break;<br>
>Â Â else<br>
>Â Â Â Â break 3;<br>
> <br>
> becomes<br>
> <br>
>Â Â if (foo)<br>
>Â Â Â Â break for;<br>
>Â Â else<br>
>Â Â Â Â break switch 3;<br>
> <br>
> and it is much more obvious what is going on.<br>
<br>
</div>
</div>
If we are willing to pile up keywords in that manner, an
alternate possibility is to spell a value-returning break in
a different way:<br>
<br>
    return switch <expression>;<br>
<br>
Then your example can become (I have added the implicit
context):<br>
<br>
    switch (…) { case 17 -> {<br>
        …<br>
        for (…) {<br>
          ...<br>
          if (foo)<br>
            break;<br>
          else<br>
            return switch 3;<br>
        … }<br>
      … }<br>
    … }<br>
<br>
The additional advantage of this approach is that it
completely eliminates the syntactic ambiguity between<br>
<br>
    break variableName;<br>
<br>
and<br>
<br>
    break labelName;<br>
<br>
Given that we think most occurrences of “return switch†(or
“switch returnâ€, take your pick) will be abbreviated by
-> anyway, this might be an acceptable approach.<br>
<br>
You can then still choose to go ahead and also allow things
like<br>
<br>
    break for;<br>
    break switch;<br>
    break while;<br>
    continue for;<br>
    continue switch;<br>
<br>
but that can be a separate decision; these become simply a
way to avoid using statement labels.<br>
<span class="m_-7422116221906509852m_-5477076865366105268HOEnZb"><font color="#888888"><br>
—Guy<br>
<br>
</font></span></blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="m_-7422116221906509852m_-5477076865366105268gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div style="line-height:1.5em;padding-top:10px;margin-top:10px;color:rgb(85,85,85);font-family:sans-serif"><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(213,15,37);padding-top:2px;margin-top:2px">Kevin
Bourrillion |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(51,105,232);padding-top:2px;margin-top:2px"> Java
Librarian |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(0,153,57);padding-top:2px;margin-top:2px">Â Google,
Inc. |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(238,178,17);padding-top:2px;margin-top:2px"> <a href="mailto:kevinb@google.com" target="_blank">kevinb@google.com</a></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</div></div></div>
</blockquote></div></div></div><div><div class="h5"><br><br clear="all"><div><br></div>-- <br><div class="m_-7422116221906509852gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="line-height:1.5em;padding-top:10px;margin-top:10px;color:rgb(85,85,85);font-family:sans-serif"><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(213,15,37);padding-top:2px;margin-top:2px">Kevin Bourrillion |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(51,105,232);padding-top:2px;margin-top:2px"> Java Librarian |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(0,153,57);padding-top:2px;margin-top:2px"> Google, Inc. |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(238,178,17);padding-top:2px;margin-top:2px"> <a href="mailto:kevinb@google.com" target="_blank">kevinb@google.com</a></span></div></div></div></div></div></div></div>
</div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="line-height:1.5em;padding-top:10px;margin-top:10px;color:rgb(85,85,85);font-family:sans-serif"><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(213,15,37);padding-top:2px;margin-top:2px">Kevin Bourrillion |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(51,105,232);padding-top:2px;margin-top:2px"> Java Librarian |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(0,153,57);padding-top:2px;margin-top:2px"> Google, Inc. |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(238,178,17);padding-top:2px;margin-top:2px"> <a href="mailto:kevinb@google.com" target="_blank">kevinb@google.com</a></span></div></div></div></div></div></div></div>
</div>