C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] labels

From: Bjarne Stroustrup <bjarne_at_[hidden]>
Date: Wed, 12 Aug 2020 09:21:37 +0200
On 8/11/2020 11:54 PM, Florian Weimer via Liaison wrote:
> * Bjarne Stroustrup via Liaison:
>
>> What benefits was this supposed to give programmers?
> Labels at the end of blocks?
>
> The most common use is an end label in an outer loop, so that it's
> possible to continue the loop from within a nested loop.
>
> for (int i = 0; i < n; ++i) {
> for (int j = 0; j < m; ++j) {
> if (exit_condition(i, j))
> goto continue_outer;
> }
> continue_outer:
> ;
> }


I consider adding a semicolon there a very minor inconvenience. *If* I
considered it an improvement not to add the semicolon and wanted to
change the rule that a label labels a statement, I'd ask myself

Why hasn't anyone bothered for almost 50 years? this cannot be all that
important even if I like it.

What confusions will emerge in the community? Anyone saying just
something like "a label labels a statement" will cause confusion and/or
attract corrections and discussions on the Web; all the teaching
material from K&R1 onwards are no long completely correct and won't be
brought up-to-date for decades.

When will all tool chains I rely on be completely updated? If I write a
piece of code using the new rule, it won't compile on any compiler or
tool that hasn't been updated. Major compilers will comply reasonably
soon (and may, as Richard point out, quietly start accepting programs
that are illegal C++ thus exporting the benefits and problems to C++) ,
third-party tools with smaller user communities may never upgrade. There
are hundreds, probably thousands, of tools "out there" that rely on some
sort of C or C++ parsing. Prudent coding standards would have to ban the
new construct to avoids damaging usability.

Received on 2020-08-12 02:25:08