04.12.19 22:12, Skip Montanaro пише:
This is my last post on this, at least as far as specific usage
instances are concerned. See my question about PEP 7 below. If that is
a discussion people think worthwhile, please start a new thread.
if (!VISIT(...)) {
return 0;
}
if (!VISIT(...)) {
return 0;
}
if (!VISIT(...)) {
return 0;
}
instead of just
VISIT(...);
VISIT(...);
VISIT(...);
That seems easily solved with the VISIT-as-macro calling
_VISIT-as-inline function.
I do not understant what problem do you want to solve. VISIT() in
symtable.c is:
#define VISIT(ST, TYPE, V) \
if (!symtable_visit_ ## TYPE((ST), (V))) \
VISIT_QUIT((ST), 0);
It literally calls other (non-inlined) function, check its result and
returns from the caller function (in VISIT_QUIT). I do not understand
how inline function can help here.
In any case, I was just somewhat surprised to see relatively new code
using macros where it seemed inline functions would have worked as
well or better.
In these cases macros cannot be replaced by inline functions because
inline function do not have access to variables of the caller and cannot
affect the control flow of the caller.
The new code follows idioms used in the old code. There are also many
other cases where macros save as from duplicating code and cannot be
replaced with inline functions (C++ exceptions, templates, constructors
and constant expressions could replace macros in some cases, but CPython
is implemented on pure C, not even using all features of the recent
standard). Don't afraid macros, they are the part of the language and
pretty safe if use them properly.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/3Z6MO5CPOEGYEVW7YOKPP5H5BGAR5RUX/
Code of Conduct: http://python.org/psf/codeofconduct/