[issue37812] Make implicit returns explicit in longobject.c (in CHECK_SMALL_INT)
Tim Peters
report at bugs.python.org
Fri Sep 20 02:48:02 EDT 2019
Tim Peters <tim at python.org> added the comment:
Sorry, but there was nothing wrong with the CHECK_SMALL_INT macro, to my eyes, to begin with - except that it was burdened with an over-elaborate "do ... while(0)" wrapper.
Not all macros are _intended_ to be "cheap functions". Like this one, some are intended to be merely textual replacement, to minimize tedious and error-prone redundant typing, in a specific file. Even "bulletproofing them" with tricks like "do ... while(0)" cruft is counterproductive in such cases. They're not _intended_ to capture abstractions, neither for general use. This one was intended to check its argument and possibly return, exactly what its expansion did (after mentally tossing out the distracting "do while" noise).
Nobody competent to address logic errors in longobject.c was confused about that in the slightest. Knowing the details of how small integers may be cached is part of what "competent" means in this context, and what the macro does is so simple it's no burden to learn or to use.
Is there an "aesthetic code cleanup" patch that's ever turned out well? ;-)
----------
nosy: +tim.peters
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37812>
_______________________________________
More information about the Python-bugs-list
mailing list