C++ Logo

std-proposals

Advanced search

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

From: Andrew Tomazos <andrewtomazos_at_[hidden]>
Date: Sun, 21 Apr 2024 06:18:45 +1000
No, I said that `unless` is claimable as a full keyword. It means it
occurs so infrequently in existing code that the committee would accept it
as a new keyword, even though it might break a tiny amount of uses of the
identifier `unless`, because there are so few in the field.
  -Andrew

On Sun, Apr 21, 2024 at 6:08 AM Yexuan Xiao <bizwen_at_[hidden]> wrote:

> Thank you for your encouragement. Introducing a new keyword would be a
> breaking change, so I’m leaning towards a compromise solution. The use of
> if ! or if not should suffice. I’ve just analyzed the Rails codebase, and
> the usage of unless is nearly one-fifth that of if. So, while the issues it
> addresses aren’t as frequent, it can still be widely used.
>
> ------------------------------
> *From:* Andrew Tomazos <andrewtomazos_at_[hidden]>
> *Sent:* Sunday, April 21, 2024 3:53
> *To:* std-proposals_at_[hidden] <std-proposals_at_[hidden]>
> *Cc:* Yexuan Xiao <bizwen_at_[hidden]>
> *Subject:* Re: [std-proposals] if !(condition)
>
> * In my estimation `unless` is claimable as a full keyword:
>
> unless (is_pickle())
> put_in_sandwidch();
>
> (There is existing practice in another language, can't remember which one.)
>
> ** It's hard to believe, but: `if (!expr)` occurs once in every 60 lines
> of C++ code, or about 5 times per source file.*
>
> That's pretty amazing, I would never have guessed that.
>
> * You are correct that `while(!expr)` is much rarer. Only 1 in every 5000
> lines or so.
>
> * You are also correct that `operator!` overloading is almost non-existent.
>
> -Andrew
>
>
>
>
> On Sun, Apr 21, 2024 at 3:34 AM Yexuan Xiao via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
> Firstly, I believe that this particular case in if statements is the most
> common, so it’s my main focus; secondly, the ‘if not’ construct already
> exists and is widely used elsewhere, making it more readily acceptable.
> Therefore, the proposal will focus exclusively on if statements rather than
> loop statements.
> ------------------------------
> *From:* Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf
> of Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]>
> *Sent:* Sunday, April 21, 2024 1:18
> *To:* std-proposals_at_[hidden] <std-proposals_at_[hidden]>
> *Cc:* Sebastian Wittmeier <wittmeier_at_[hidden]>
> *Subject:* Re: [std-proposals] if !(condition)
>
>
> I would expect a comment about "while" and "do while" (and possibly "for").
>
>
>
> Would you propose adding ! there, too, oppose it, leave it neutrally open,
> invite anybody to write a paper or want to see, how if !() works out? Or is
> it not possible there?
>
>
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* Yexuan Xiao via Std-Proposals <std-proposals_at_[hidden]>
> *Gesendet:* Sa 20.04.2024 18:09
> *Betreff:* [std-proposals] if !(condition)
> *An:* std-proposals_at_[hidden] <Std-Proposals_at_[hidden]>;
> *CC:* Yexuan Xiao <bizwen_at_[hidden]>;
> 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.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
>

Received on 2024-04-20 20:18:58