Why is there no or or and ?
timon.gehr at gmx.ch
Thu Feb 16 21:14:29 PST 2012
On 02/17/2012 06:02 AM, Jonathan M Davis wrote:
> On Thursday, February 16, 2012 23:53:34 bearophile wrote:
>>> And I'm actually mildly shocked that anyone (at least any programmer)
>>> 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
> I'm surprised that anyone would think that and was better than&&.
> - Jonathan M Davis
The editor would highlight the keywords, so you definitely would not
confuse them for variables. This is already true for 'is' and 'in'.
I don't need any alternative operators though, I'd rather introduce some
new ones, like the implication operator '==>'.
More information about the Digitalmars-d