5 ms·
Consider (&& a b) and (|| a b) for no uncertainty over operator precedence and easy variadic representation (&& a b c) at the cost of zero additional parenthese
by JonChesterfield 3y ago
Consider (&& a b) and (|| a b) for no uncertainty over operator precedence and easy variadic representation (&& a b c) at the cost of zero additional parentheses.
- namrog84 3y agoWhile true and might be easy to read in the example context of a b c I'd imagine having the && separator in real world conditions to be far more readable and clear for vast majority if people
- TylerE 3y agoPipe looks far too much like a 1 or lowercase ell.
- trealira 3y agoI actually think the variadic logical and is more readable, and wish more languages had it. As long as all the arguments are lined up vertically, you can think of it as a sequence of tests for true that exits at the first failure. It's more obvious with the variadic operator. Contrived comparison: if (a != null && x != 0 && a.use_it(x)) { ... } (if (and (not (null a)) (/= 0 x) (use-it a x)) ...)
- NegativeLatency 3y agoMost, and possibly all languages I've used day to day do not have prefix operators like that.
- ant6n 3y agoPrefix operators considered harmful for readability.
- tasty_freeze 3y ago... at the cost of having parentheses around every subexpression.
- torstenvl 3y agoI hate Excel for this very reason.