C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposal regarding labeld breaking and continuation

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Fri, 17 Feb 2023 14:29:28 +0000
On Fri, Feb 17, 2023 at 12:30 PM Hypatia (of) Sva via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> for(int i = 0; i < n; i++)
> outer: {
> for(int j = 0; j < n; j++) {
> if(f(i,j)) break outer;
> }
> }


A suggestion for alternative syntax:

      for ( unsigned i = 0u; i < n; ++i )
      { <- outer
              for (unsigned j = 0u; j < n; ++j )
              {
                  if ( f(i,j) ) break outer;
              }
      }

Maybe give the programmer the option of labelling the closing brace
rather than the opening brace as follows:

      for (unsigned i = 0u; i < n; ++i )
      {
              for (unsigned j = 0u; j < n; ++j )
              {
                  if ( f(i,j) ) break outer;
              }
      } <- outer

Received on 2023-02-17 14:29:39