Java: break and continue with an optional boolean condition

David Lloyd david.lloyd at redhat.com
Mon Jun 11 13:10:14 UTC 2018


Is this:

    break (i > 10);

really substantially better than:

    if (i > 10) break;

?

On Mon, Jun 11, 2018 at 7:54 AM, George Radev <georgeradev at gmail.com> wrote:
> Dear amber-dev team,
>
> Would you consider a proposal for extending break and continue with an
> optional boolean condition as reasonable?
> The idea can be summarized in the code example:
>
>     for (;;) {
>         ...
>
>         break (i > 10);
>         ...
>
>         continue (i <= 12);
>
>         ...
>
>     }
> //syntax will be:  break/continue [label] [boolean expression];
>
> This will increase the code readability of for, do and while; and leave
> additional if and some curly brackets out of the picture.
>
> My arguments for such extension is that it solves the expressiveness
> concerns that Donald E. Knut explain in its article "Structured Programing
> with GOTO statements" by describing the Ole-Johan Dahl proposal for [loop
> while repeat] structure where the condition is not bound to the beginning (
> do...while()) nor to the end of the repeating block (while()...) which
> makes the controlled flow of the program more effective.
>
> Thank you for your time and consideration!
>
> With Regards,
> George Radev



-- 
- DML


More information about the amber-dev mailing list