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 14:42:57 +0100
> That naming conventions are not actual semantics?

Sure, but what is the technical reason why you need different syntax?
The argument seems to be "I'm uncomfortable with label: being able to
give a name to goto targets and loops."

Similarly, I can be uncomfortable with lower-case identifiers being
permitted to refer to both variables and types in Java. However, no
one seriously suggests enforcing semantic naming because it's just not
a problem. Linters and compiler warnings can be used to enforce
conventions. Languages shouldn't be designed with stricter rules
solely for the purpose of personal comfort and personal preference of
some users.

Personally, I take no issue with "label:" being both a potential goto
and break target. I might even prefer that. Why should your personal
preference be enshrined into the language through stricter, but
technically unnecessary rules? You can enforce your personal
preferences through naming conventions (potentially linter-enforced),
and I can have my laxer rules through the language default.

> Are member function bodies not function bodies?

They are, but they're also not special. You can understand the control
flow in a member function from top to bottom, just like with a free
function (except for gotos).

Some symbols may be defined or declared elsewhere, potentially
somewhere else in the class body, or in a completely different file.
This is the case for free functions as well as for member functions.
When I use "malloc()" in a free function, it's also not guaranteed
that malloc has been declared, let alone defined above, in the same
source file.

Member function bodies can refer to other members before those members
have been declared, but this is no worse than referring to symbols
that aren't even declared in the same file, but in some included
header.

Received on 2024-12-20 13:43:11