WHUI! (was Re: [Python-Dev] Proposal: C API Macro to decref and set to NULL) (original) (raw)
Tim Peters tim.peters at gmail.com
Fri Jul 16 02:45:20 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 decrefand set to NULL)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Christian Tismer]
How about
if ( 0 || || VISIT(self->readline) || VISIT(self->read) || VISIT(self->file) ) return 1;
Well, "0 ||" doesn't do anything at all, it doesn't return the return value of the visit() callback if a non-zero one is returned, it's clumsier to write and read than what Jim checked in, and since Py_VISIT does exactly one thing in exactly one context (tp_traverse implementations), I have no fear at all of the "hidden" return. Almost all tp_traverse implementations can (and should) look exactly alike:
Py_VISIT(member1); Py_VISIT(member2); ... Py_VISIT(member_n); return 0;
and Py_VISIT has no other use case. Why complicate it? Sticking a "return" in a general purpose macro could be horrid indeed; Py_VISIT is so specific, and of such limited use, there's simply nothing to fear here. It makes writing "correct by casual inspection" tp_traverse implementations dead easy, and has no effect on anything else. A continued +1 for the simplest thing that could possibly work here (which is happily a 100% solution in this case too).
- 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 decrefand set to NULL)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]