Doxygen is old-fashioned and hard to install. And I hardly encountered any project using CWEB.
On the other side, Sphinx has a C domain.
The FFI way is much cleaner.
p. 112 introduces a trick based on pointer arithmetic:
#include <stdio.h>
int main(){
char *list[] = {"first", "second", "third", NULL};
for (char **p=list; *p != NULL; p++){
printf("%s\n", p[0]);
}
}
I dislike this cleverness. I prefer a more explicit index variable.
I prefer explicitly return 0
from main
:
- I like explicitness.
- It is balanced with other non zero/failure returning.
- Do not bother remember another special rule of
main
.
The author prefers (2+0.0)
over (dobule) 2
.
I think here (double)
is much clearer and much more straight than +0.0
.
The author prefers short string (for example single character) to global all-caps enums.
I dislike global all-caps enums, too. But I also dislike using short string. If I have to choose one, I would prefer global enums (not necessary all-caps).
Let me review the author's opinion:
I don't want to type these messes, and I use them so infrequently that I have to look them up every time
You do not have to. The IDE/editor will complete them for you.
all caps like yelling
You can ues CamelCase
.
We sometimes need to combine flags.
In theses cases, I prefer neither enum nor string.
Instead, I prefer separated functions,
like readAndAppendLines
and readAndOverwriteLines
.
On the plus side of enums, you have a small, fixed set of symbols, so if you mistype one, the compiler stops and forces you to fix your typo. With strings, you won't know you had a typo until runtime.
This is the very reason I prefer enum over string.
If the errors were short strings, extension by others would be trivial.
There are not true extension. It is trivial to add those 'extension', but it is hard to distinguish those 'extension' with misuse.
goto
, it is generally harmful but is a common present-day idiom for cleaning up in case of different kinds of errors, and it is often cleaner than the alternatives. (p.123)
First goto
is restricted with in function,
so it is not that evil.
Second, for a language without try-catch, nested function and lambda, there are not many choices.
don't use switch
The alternative to the
switch
is a simple series ofif
s andelse
s. (p.124)
I dislike the fall-through of switch
in C, too.
But I still think sometimes switch
is more readable than if
and else
.
License: 0BSD