WHUI! (was Re: [Python-Dev] Proposal: C API Macro to decref and set to NULL) (original) (raw)
Jim Fulton jim at zope.com
Tue Jul 13 17:19:59 CEST 2004
- Previous message: WHUI! (was Re: [Python-Dev] Proposal: C API Macro to decref and set to NULL)
- Next message: WHUI! (was Re: [Python-Dev] Proposal: C API Macro to decref andset to NULL)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tim Peters wrote:
[Jim Fulton, on non-zero return values from a visitproc] ...
First, I don't like this macro, based on my own experience writing macros that hide returns. :)
Except VISIT is useful only inside a tptraverse implementation, and all such implementations look exactly the same (VISIT, VISIT, VISIT, ..., sometimes with a surrounding loop). That's not an accident, since the only purpose of a tptraverse implementation is to VISIT containees. So it's a special-purpose macro for a highly specific and uniform task, not a general-purpose macro that has to play well in arbitrary contexts.
I still don't like it, because it hides the return.
I'd rather do:
if (self->foo != NULL && (vret = visit(self->foo, arg)))
return vret;
than
VISIT(self->foo)
So I'm not interested in the macro myself. :)
I'll say again that I don't like calling the return from the visit proc an error indicator, because it's not, and because it goes against the common idiom of using a negative return to indicate an error. I think that these common idioms are important, because they help us understand the code we're reading more easily.
Jim
-- Jim Fulton mailto:jim at zope.com Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org
- Previous message: WHUI! (was Re: [Python-Dev] Proposal: C API Macro to decref and set to NULL)
- Next message: WHUI! (was Re: [Python-Dev] Proposal: C API Macro to decref andset to NULL)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]