C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Bringing break/continue with label to C++

From: Jan Schultke <janschultke_at_[hidden]>
Date: Fri, 20 Dec 2024 15:36:42 +0100
> > then do the sets of labels NEED to be separated, strictly speaking, from a technical viewpoint?
>
> From a purely technical viewpoint, an unstructured jump construct like
> goto has the potential to significantly increase
> the cyclomatic complexity of the code.

In other words, no. An increase in cyclomatic complexity is not
something which categorically makes a feature impossible to have. It's
just a metric which, ideally, should be kept low.

Also, adding labels has no impact on cyclomatic complexity. Consider
the following to code snippets:

> while (true) break;

> a: b: c: d: e: f: g: h: i: while(true) break i;

Despite the second code snippet containing many more labels, the
cyclomatic complexity is identical.

Adding a label only increases the "intuitively perceived cyclomatic
complexity", and ONLY if you don't follow a naming convention that
disqualifies a loop label from being a goto target, as I've suggested.

> See, the 'dislike' for goto isn't a 'dislike' at all.

Yes, it is. We're like 10 messages into this and still only talking
about "perceived complexity" and not a single problem has been brought
up that can't be resolved with naming conventions.

Received on 2024-12-20 14:36:56