Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

C++ has "and"/"or"/"not" etc., so you can do

    if(not A and B)
but I'm not sure I've ever seen anyone do it. http://en.cppreference.com/w/cpp/language/operator_alternati...

To get them in C, see the note about iso646.h in the link.



I don't think it really improves readability. All the programmers are familiar with && and ||, and using something else will just confuse people.

Also, it's not really that hard to #define it yourself, instead of using includes.


I definitely wouldn't use them because they are unfamiliar. However, in my head I pronounce "&&" as "and" and "&" as "bitand", so using and/bitand over &&/& would reduce a depressingly not-uncommon typo for me. However, on balance, not worth it to me.

Note that in C++ they are keywords which is superior to macros.


How are they superior?


For one, a macro "and" would prevent you from using "and" as the name of a struct field, while a keyword will not. Error reporting will be better too. The differences don't seem all that big though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: