003 - Trigraph
The code snippet above performs short-circuit evaluation:
HandleError() will only happen if
!ErrorHasOccured() evaluates to
However, instead of
||, which is normally used for this, the snippet above
??!??! which most C compilers still allow.
Similar to spoken languages, some programming languages support digraphs and trigraphs - groups of two or three characters used to symbolise one character.
Before the current QWERTY keyboard layout was widespread, some keyboards didn’t
have special characters such as
|. To make things easier for programmers,
the C preprocessor made is so that typing
??! is the same as typing
Similar rules exist for other characters which were less common on keyboards at
the time, such as
While largely irrelevant nowadays, many C compilers still support this. This
makes it possible to replace
??!??! anywhere in your C code.
Needless to say, using
??!??! instead of
|| in code is both unnecessary and
something that few are familiar with, making this a bad practice for production