Why is there no or or and ?

Jonathan M Davis jmdavisProg at gmx.com
Thu Feb 16 21:02:20 PST 2012


On Thursday, February 16, 2012 23:53:34 bearophile wrote:
> > 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.

Seriously? && and || are _way_ more readible, because they're obviously not 
functions or variables. It's immediately obvious what the operators are when 
scanning code. That's not the case when the operators are words instead of 
symbols. I'm certain that you'd have quite a few programmers up in arms if you 
tried to change && to "and" and || to "or." And having multiple operators 
which do exactly the same thing is a horrible idea which reduces code 
readibility. So, even adding them as alternate options is a really bad idea 
IMHO.

I'm surprised that anyone would think that and was better than &&.

- Jonathan M Davis


More information about the Digitalmars-d mailing list