The 'Null Statement'
The Statement Without Meaning
My initial plan was to write a long, meandering introduction to the weird and
wonderful world of C
programming, but I figured I will just cut to the chase:
A demonstration
if (x) {
;
} else {
;
}
void real_function(void) {
;
;
;
;
;
;
}
These blocks of C
code are both correct and valid.
It was revealed to me recently that the semi-colon is a statement in and of it self. The two blocks of code do not do anything, but they are valid, and that is what is most important.
This statement is apparently referred to as the null statement and it helped
improve my understanding of C
.
Loops
Before falling asleep I often like to read code from random projects hosted on Github.
When reading C
code, particularly code written from years ago, I noticed
while
loops written like this:
while (;) {
/* something... */
}
This loop never terminates (unless an explicit break
statement is in there somewhere).
Being generation zoomer means I only started programming in C
after
stdbool.h
was introduced.
In my mind, while
loops that are meant to run indefinitely are written like this:
#import <stdbool.h>
while (true) {
/* something... */
}
They did not have stdbool.h
before my time. This era was BB, “before boolean”.
The release of C99
ushered in a new age for developers, they finally were able
to grasp in their hands the cosmic powers of true
and false
, the ability to
deal judgement on expressions, we finally had access to the once fabled values
of truth.
These new and shiny constructs were not dirtied by the primitivisms of
“binarism”, (the natural mode of which machine-kind operates).
Discarded were the 1’s and 0’s, relegated to the deep lore of ancient history.
Once a mighty commander of mankind and the gatekeeper of technological
achievement, now appearing only to serve us bitter memories of by-gone days.