C++ Logo

std-proposals

Advanced search

Re: [std-proposals] if !(condition)

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Sat, 20 Apr 2024 21:01:25 +0200
On 20/04/2024 18.09, Yexuan Xiao via Std-Proposals wrote:
> I've wrote a proposal that suggests allowing the omission of the outermost parentheses to simplify the conditions in if statements:
> https://storage.nykz.org/proposals/if-not/
>
> Please share your comments.

A "condition" might be a declaration. The "equivalent" syntax
"!(condition)" is not valid C++ if the "condition" is a declaration.

Thus, your proposal seems incomplete.

You quote 1500 simplification opportunities in LLVM and 2300 ones
in GCC. How many "if" statements are there in total, in each of
those codebases?

Beyond that, I'm strongly opposed: this delivers no benefit at all.
Being able to omit nested parentheses in the condition in some
cases (but not others, if the negation isn't at the top level)
is insufficient motivation for another wart in the language,
in my view.

Someone hiding expression syntax in a macro is just misguided;
I have no sympathy whatsoever.

Jens

Received on 2024-04-20 19:01:33