3 ms·
Mmm. You've given a code snippet while Zak had a single macro call. Let's make your code into a function with signature: def atdt_exception_suppression(*li
by roenxi 5y ago
Mmm. You've given a code snippet while Zak had a single macro call. Let's make your code into a function with signature:
def atdt_exception_suppression(*list_of_fns):
...
What you've done is leverage the fact that functions are first class objects in Python (ie, can be passed as arguments) to achieve the same result as a macro. Which is cool, it works. Probably slightly better than a macro for this use case because we get a neat function boundary.
But macros are a powerful option because it doesn't matter if functions are first class or not. If you are using a language where functions aren't first class objects, a macro system would let Zak implement anyway.
So you are correctly identifying that Python can implement this in an alternate way as a function, but a macro system is sufficient to do this and a whole batch of other tricks even if first class functions aren't available as a feature.