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 tp_traverse 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 tp_traverse 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4