About Linus taste
Closed this issue · 1 comments
Since you're quoting Linus Torvalds about his opinions of what is good and bad taste, I'd like to point out that he consider typedef struct list_item list_item;
to be very bad taste.
Please don’t use things like vps_t. It’s a mistake to use typedef for structures and pointers. When you see a
vps_t a;
in the source, what does it mean? In contrast, if it says
struct virtual_container *a;
you can actually tell what a is.Lots of people think that typedefs help readability. Not so. They are useful only for:
[Some listed rules. See link to read them.]
Maybe there are other cases too, but the rule should basically be to NEVER EVER use a typedef unless you can clearly match one of those rules.In general, a pointer, or a struct that has elements that can reasonably be directly accessed should never be a typedef.
https://www.kernel.org/doc/html/v4.10/process/coding-style.html#typedefs
Hey @klutt, yes, that’s a well known and popular reference! I agree with the assessment and would be happy to take a PR.
To manage expectations, the goal of this repo is to explain the technicalities behind a particular linked list implementation that Linus considered elegant, not to write code that would make Linus happy…