WHUI! (was Re: [Python-Dev] Proposal: C API Macro to decref
and set to NULL)
Tim Peters
tim.peters at gmail.com
Tue Jul 13 17:33:42 CEST 2004
[Jim Fulton]
> 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)
I don't believe you <0.5 wink>. Here, rewrite this:
VISIT(self->readline);
VISIT(self->read);
VISIT(self->file);
VISIT(self->memo);
VISIT(self->stack);
VISIT(self->pers_func);
VISIT(self->arg);
VISIT(self->last_string);
VISIT(self->find_class);
return 0;
That's the current Unpickler_traverse, and it's utterly typical. In
context, hiding the return doesn't matter: no computation is done
between VISIT invocations.
> So I'm not interested in the macro myself. :)
That's fair, but the lack of one will make correct docs for
tp_traverse functions clumsier to write and read (you'll have to write
out the tedious & error-prone (*because* tedious) expansion instead --
and that will encourage readers to code their tp_traverses in this
brittle way too).
> I'll say again that I don't like calling the return from the visit
> proc an error indicator, because it's not,
I agree (again <wink>).
> and because it goes against the common idiom of using a negative return to
> indicate an error.
Well, it's not an error indicator (although it *may* be), so error
idioms don't apply. I'll change that bit of the docs.
More information about the Python-Dev
mailing list