P2971 Implication

 

offers another way to write non-negated if:

 

condition => instruction

 

 

Implication shortcuts, if condition is false. Then the whole expression is automatically true, without having to call instruction.

 

So the parantheses for if (!(condition)) could be avoided by using

!(condition) => instruction.

 

===========================

 

 

In languages with both if not any unless,

if not is rather used, if the condition is unlikely, and unless is rather used, if the condition is likely.

 


 

-----Ursprüngliche Nachricht-----
Von: Yexuan Xiao via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Sa 20.04.2024 18:09
Betreff: [std-proposals] if !(condition)
An: std-proposals@lists.isocpp.org <Std-Proposals@lists.isocpp.org>;
CC: Yexuan Xiao <bizwen@nykz.org>;
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@lists.isocpp.org
 https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals