C, what the fuck??!
bowero.nl
bowero.nl
C++17 actually removed support for these.
Outside of silly games like IOCCC, did anybody actually use trigraphs? I find it really hard to believe that anybody tolerated trigraphs for serious C programming. Was there an obscure European government agency that actually wrote code with trigraphs?
From http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n291...
> The biggest argument against deprecating trigraph is the fact that we know there are source code from world-wide companies, based on an internal survey of our customer problem reports that make heavy use of trigraphs for one reason or another, and customer testimonials. Google code search doesn't find them because these are proprietary code. Further discussions with some of these customers have shown serious dissatisfaction with WG21’s intention to deprecate trigraphs, because they do not wish to make any changes to their source code. It doesn't seem fair to force this group of existing users to change their source code for no apparent benefit, other then reducing an annoyance to another group.
ISO 646 is probably nowhere near as relevant to their argument as EBCDIC is.
> Trigraph deprecation is vexing for existing world-wide companies (of which IBM is one such user) because of their use of EBCDIC variant code pages. It makes it difficult to start in a code page neutral manner, establish what the active code page is, then start using invariant characters. We use a pragma filetag("IBM-1047") to toggle the code page, then we can use #. Prior to that we are in a code page neutral environment and must use the trigraph ??=
%:%: ##
compl ~
not !
bitand &
bitor |
and &&
or ||
xor ^
and_eq &=
or_eq |=
xor_eq ^=
not_eq !=
C only has basic ones (still more intuitive than trigraphs). <: [
:> ]
<% {
%> }
%: #
Last time, I had to type a C program on a touchscreen, and those symbols were extremely difficult to enter. I knew digraphs can help, but then realized that I couldn't use the digraphs for logic operators without programming C under C++.It's still clickbait, though.
I am also not aware of any professional who would use multiple question marks in any kind of serious code that could be read by anybody else because that kind would reflect negatively on the perception of his professionalism.
`test.c:6:31: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]`
Therefore the probability of this happening by accident is 0 but the probability of this happening by incompetence (after the trigraph already slipped in undetected) hovers around 82%.
A good compiler (eg: gcc) will warn if any token is interpreted as a trigraph
Edit: digraph works a bit differently [0]
In code written by people whose job it is, in part, to write code, i.e. what I would call professionals, multiple question marks do sometimes occur.
* Professionals want to appear professional to the people who pay them.
* People who read the code can have an influence on the people who select which professional gets hired. (At least negatively if they find examples of poor practices.)
* Professionals therefore avoid any behavior that would be interpreted as unprofessional.
* Multiple question marks appear unprofessional and are therefore avoided. (Or would you concur???)
* I could not find a counterexample in my memory.
If this can be interpreted in a "no true Scotsman" way then it would be: "All Scotsmen who showed the behavior have been denied the citizenship." and then in turn they really wouldn't be true Scotsmen anymore because they lost the citizenship.
Seems like a really weak assumption to me. Seen enough swear words etc in actual code bases, "???" in bug trackers, ... to think people would worry about the number of "?" they use in comments.
I definitely add comments with tons of questions and potential trigraphs when I use punctuation in lieu of actual cursing. Don't get me wrong. I curse a lot in comments, too.
TL/DR: bad code -> angry comments
However: https://www.jetbrains.com/help/phpstorm/refactoring-source-c... ?
!didIMakeAMistake() || CIsWrongHere();
> If you understand how short-circuit evaluation works, you can understand that this will result in the following: if (!didIMakeAMistake())
CIsWrongHere();
Can someone explain this? I’d have thought that was right without the !Function calls have the highest priority here, followed by logic NOT and logic OR.
!didIMakeAMistake() || CIsWrongHere();
!didIMakeAMistake() is evaluated first (or you can say didIMakeAMistake() is executed and evaluated first, then its result is inverted and checked), if it's true, evaluation is finished. If it's false, CIsWrongHere(); is evaluated.It is indeed equivalent to
if (didIMakeAMistake()) /* !didIMakeAMistake() == false? */
CIsWrongHere();
Without the invertion.They only existed because really old terminals sometimes didn't have various punctuation characters used by C so they needed the ugly workaround so people trapped on those terminals wouldn't be left out in the cold.