3 ms·
Emacs Lisp* has a system called "advice" that's maybe a bit clumsier than Python's, but is also more powerful. The relationship between decorator and decorated
by b3morales 5y ago
Emacs Lisp* has a system called "advice" that's maybe a bit clumsier than Python's, but is also more powerful. The relationship between decorator and decorated [is configurable][0]. For example, the decorated function could be called conditionally on the result of applying the decorator to the arguments, something like:
def _combined(args):
return decorator(args) and original(args)
It can also be applied retroactively, not just at the decorated function's definition. This is extremely handy in the context of configuring your text editor, but I admit I wouldn't like it in a program I was working on with other people. (Basically a form of monkeypatching.)
* Granted not really used for general-purpose programming like Python.
[0]:https://www.gnu.org/software/emacs/manual/html_node/elisp/Advice-Combinators.html https://www.gnu.org/software/emacs/manual/html_node/elisp/Ad...
- creamytaco 5y agoEmacs Lisp has macros which are a lot more elegant (not to mention powerful) than Python decorators which comparatively, are nothing more than a kludge.