4 ms·
Why not tho? Decorators are very explicit markers of higher functions. When I see one, I know what's for.
by sscarduzio 4y ago
Why not tho? Decorators are very explicit markers of higher functions. When I see one, I know what's for.
- LaMarineta 4y ago
- henrydark 4y agoIt's rare that all users of a function will want it to be "production" or "parallel" or the rest in the piece. Applying these functions as decorators, i.e. with @, means you can't run the non parallel version, or the test not in production, etc. In the end, decorators, though nice on the first day of usage, reduce composability by restricting usage to whatever you wanted on that same day. (this is not a general remark, it doesn't apply to DSLs that use decorators, e.g. flask)
- dragonwriter 4y agoTo the extent that this is a real issue, you could just use a decorator that exposed the wrapped function as an attribute of the returned function object. You could even write a higher order function, callable as a decorator, that would transform a decorator that didn't do this into one that was otherwise identical that did.