Why is there no or or and ?
bearophileHUGS at lycos.com
Thu Feb 16 20:53:34 PST 2012
> possible enhancement request? or is there a good reason it is not in
> the language?
I have asked for them, but Walter doesn't want, he thinks C/C++ programmers will not use them... :-( Despite D != C/C++.
Jonathan M Davis:
> And I'm actually mildly shocked that anyone (at least any programmer) would
> think that "or" and "and" were more readable. The fact that operators aren't
> words is a _major_ boon to code readibility.
This is very very wrong. Of course that "or" and "and" are more readable. When you read "and" it's immediate to think it's probably related to the AND logical or binary operation more than meaningless symbols that are unrelated to "AND".
"or" and "and" are about as long as those symbols in char count, quicker to write because they are lowercase letters instead of symbols, and they are much simpler told apart from bitwise & |. This avoids some bugs where people use "&&" where they want to use "&" or the other way around. Such bugs are so common that D have had to introduce one or two rules to help avoid them.
Python got this waaaaay much better than D. Using "&" for (uncommon, in Python) binary ops, and "and" for the common logic boolean operation.
More information about the Digitalmars-d