Re:Concurrency kit – Concurrency primitives and non-blocking...
by corysama on Saturday September 12, 2015 @07:23PM
(#10209748)
To each his own. As far as macro fests go, that file looks very reasonable and legible to me. It's a single pattern repeated consistently for each function family. Writing out a dozen variants of each function explicitly would not only be much more error-prone, but would also be much harder to read and understand as a whole IMHO.
Re:Concurrency kit – Concurrency primitives and non-blocking...
by halayli on Sunday September 13, 2015 @12:07AM
(#10210328)
These are clean macros. Macros do have their place and not every time you see a macro your macro red flag should go off.
It took me less than a minute scrolling through the file to figure out what's going on.
Re:Concurrency kit – Concurrency primitives and non-blocking...
by alexforster on Saturday September 12, 2015 @09:03PM
(#10209970)
It's actually used as a way to avoid casting into and out of void* on every line. Think C++ templates. The documentation is somewhat lacking, but it's not too hard to figure out the APIs, and once you do, actually using the library is a pleasure.
Re:Concurrency kit – Concurrency primitives and non-blocking...
by sbahra on Monday September 14, 2015 @01:39PM
(#10216282)
Code duplication can also mean more errors and a lot more work for porters. You'll also see plenty of other examples in popular open-source projects such as the Linux and FreeBSD kernel. The reduction in amount of duplication is significant.
For example: For SPARCv9 for example, the macro system generates 138 functions from only the 25 or so the developer provides. To top it off, this would work across memory models as well.
This might not be the intention of the author, but if you want someone to use/hack with your library, please make it human-readable. Those macros reduce the amount of duplication, at the cost of legibility. At least include useful comments... /rant off