[Please do not mail me a copy of your followup]
n...@notvalid.com spake the secret code
<GmNaw.811873$PG2.8...@fx12.am4> thusly:
>On 18/11/2014 19:21, Martin Shobe wrote:
>Ok, but do you agree that:
>
>if( a == 5 or a == 8 )
>
>is more human readable than
>
>if( a == 5 || a == 8 )
>
>?
No. It isn't the norm in the community. (I would go farther and say
that writing if to look like a function call and bracketing the
conditional expression with additional whitespace also hinders
readability.)
>we are really doing or-operation there, so how could something else than
>or be better?
Section 2.6 of the standard calls these keywords "alternative tokens".
As far as I know, this is the only place in the standard where these
alternates are mentioned. Everywhere else logical OR is written as ||.
This is a strong hint that these alternate tokens aren't intended to
be the typical use.
The standard doesn't give a rationale for why these alternate tokens
are present in the language, but I suspect it is a legacy issue of
allowing C/C++ to be used in older environments where the keyboards
don't have some of the more "exotic" punctuation marks beyond those
found on typewriters.
Looking at the C standard, section 7.9 gives these same alternate
spellings as macros that expand to the operators. The macros are
defined in <iso646.h>. Looking up ISO 646 on Wikipedia gives a
description of this standard as the 7-bit coded character set -- in
other words it's the standardized version of ASCII.
<
http://en.wikipedia.org/wiki/ISO/IEC_646>
Now take a look at the keyboard on a common teletype:
<
http://commons.wikimedia.org/wiki/File:Mappa_Teletype_ASR-33.jpg>
Look carefully at the punctuation and you will find the following
characters are missing: {, }, |, ^ and ~. In such an environment
you would have no choice but to use the digraphs <%, %> for { and }
and the alternate keywords for operators containing ^, ~ and |.
So, you can see that these alternate spellings of the operators are
there only for compatibility with legacy environments and are not
considered to be used in "normal" situations.
--
"The Direct3D Graphics Pipeline" free book <
http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <
http://computergraphicsmuseum.org>
The Terminals Wiki <
http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <
http://legalizeadulthood.wordpress.com>