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.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds