WHUI! (was Re: [Python-Dev] Proposal: C API Macro to decref and set to NULL)

Christian Tismer tismer at stackless.com
Fri Jul 16 00:47:40 CEST 2004


Jim Fulton wrote:

[visit macro that returns]

> 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)

Just as a side note on semantically strange macros:

I did such a macro for easy error handling in Stackless months
ago, which sets an error and returns.
Before, the macro just had set an error.
The changed behavior was edited correctly in all but two places,
but I found the hidden error just by chance and very late.

Such side effects of changed macros can normally be avoided by
carefully avoiding type casts, to make sure that the compiler
recognizes incompatible changes. Unfortunately, an embedded
return statement bears *nothing* but changed semantics, and
this cannot be detected by a compiler.

This way, I managed to shoot myself seriously into the foot,
and that although I was working alone on the project for weeks.

I believe avoiding this is really a good idea.

ciao - chris
-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/



More information about the Python-Dev mailing list