Firstly: it may well be that C is "expressively impoverished". Nevertheless, C is the language that Linux is written in, and that is not likely to change. So if we find ways to make best use of those constructs which C gives us, and document them as Patterns, we can work around some of the worse short comings while still keeping the result reasonably maintainable.
Secondly: if you look at cfq_rb_root in cfq-iosched.c, you will find an rbtree with an 'optimisation' that the left-most node is cached, as in that application it is often wanted. Implementing that requires making changes inside the 'add' routine. Keeping the implementation 'open' makes it easier to build that sort of enhancement.
Thirdly: it may well be that there is a "better" pattern available using macros or inlines or whatever. In writing the article I was not inventing patterns, but simply documenting them. If doing so helps people to see the weaknesses in the patterns and thus to improve the code by applying a better pattern, then we will have achieved something very worthwhile.
Posted Jun 22, 2009 22:23 UTC (Mon) by nix (subscriber, #2304)
[Link]
Oh, I agree with all of that. I wasn't saying that this was a *bad* thing:
obviously C is a pretty damn good language to write kernels in! (I wasn't
writing a kernel at the time.)