[PATCH 1 of 7 V2] util: add a macro initializing CPython modules
gregory.szorc at gmail.com
Thu May 18 18:14:45 EDT 2017
On Sat, May 13, 2017 at 9:44 PM, Yuya Nishihara <yuya at tcha.org> wrote:
> On Sat, 13 May 2017 21:08:59 -0700, Jun Wu wrote:
> > Excerpts from Yuya Nishihara's message of 2017-05-14 12:57:57 +0900:
> > > > + (void)postinit; \
> > This line could be changed to:
> > if ((postinit) == -1) \
> > return; \
> > > Maybe I'm a bit conservative about a macro use, but my concern here is,
> > > it's so easy to make postinint never be called.
> > >
> > > PYMODULEINIT(parsers, methods, parsers_doc, 1,
> > > module_init)
> > Then it will get a warning: comparison between pointer and integer.
> > I think the benefit of code de-duplication is worth a complex marco. The
> > code using the macro won't get changed frequently so I won't worry too
> > about it being used wrongly.
> That could be a counter argument. Since it's a boilerplate code we won't
> change too often, code duplication is just okay. That's my opinion.
The duplicate code for module init already exists. This series just adds to
I'm fine with either continuing to dupe minor things, including adding a
version check. Or, we can add a macro for just the version checking and
call it 2x. Or, we can establish a convention for defining a "postinit"
function per module, invoke that 2x as part of the boilerplate, and have
each module's implementation call a helper or macro to do version checking.
Let's not make perfect the enemy of good.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mercurial-devel