From: Jeff King Date: Sat, 17 Apr 2010 14:00:53 GMT Subject: Re: [RFC/PATCH v2 0/4] A new library for plumbing output Message-ID: <20100417140053.GA10997@coredump.intra.peff.net> In-Reply-To: <201004171502.42044.jnareb@gmail.com> On Sat, Apr 17, 2010 at 03:02:39PM +0200, Jakub Narebski wrote: > Something like that (please remember that it is still in vague beginnings > of an idea stage: > > OUT_OBJECT( > OUT_FIELD("mode", OUT_MODE, tree.mode), SP, > OUT_FIELD("type", "%s", tree.object.type), SP, > OUT_FIELD("object", OUT_SHA1, tree.object.sha1), TAB, > OUT_FIELD("file", OUT_FILE(sep), tree.filename), > sep > ); Doing that would require variadic macros, which are a C99-ism. So you would have to do: OUT_OBJECT_START(); OUT_FIELD("mode", OUT_MODE, tree.mode); OUT_SP; ... OUT_OBJECT_END(); which is not all that different from what Julian has now. I do think some type-specific conversions might be handy. They don't even need to be macros. E.g.,: void output_mode(struct output_context *oc, int mode) { output_strf(oc, "mode", "%06o", mode); } OTOH, looking over Julian's last patch series, there really aren't that many that would be generally applicable, and as you can see they only save a few characters, not even a line. A few bigger objects could be factored out, but he has already done that (e.g., see wt_porcelain_unmerged in his v2 3/4). -Peff