Why is there no or or and ?

Timon Gehr timon.gehr at gmx.ch
Thu Feb 16 21:11:04 PST 2012

On 02/17/2012 05:53 AM, bearophile wrote:
> Caligo:
>> 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".

In what way is '&&' meaningless or 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,

Valid point.

> 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.

&& and & don't look the same to me. Furthermore, I have never run into 
any parser special cases except if(x=y()) and x | b<c, and then the 
error messages were actually annoying and meaningless.

> Python got this waaaaay much better than D. Using "&" for (uncommon, in Python) binary ops, and "and" for the common logic boolean operation.
> Bye,
> bearophile

Python also uses "&" for set intersection afaik.

More information about the Digitalmars-d mailing list