3 ms·
In fact, I invented a new kind of Lisp macro, the parameter macro, which decorates functions, but at compile time rather than run-time, and with much more flex
by kazinator 6y ago
In fact, I invented a new kind of Lisp macro, the parameter macro, which decorates functions, but at compile time rather than run-time, and with much more flexibility.
https://www.nongnu.org/txr/txr-manpage.html#N-00B4065C https://www.nongnu.org/txr/txr-manpage.html#N-00B4065C
An example is given of a memoization parameter macro that you invoke simply by adding :memo to the front of the parameter list, as in (lambda (:memo ...) ...). This inlines everything; the function itself rewritten to do the caching with open code, rather than wrapped with a caching function.
TXR Lisp's support for keyword arguments is also implemented as a parameter macro, using the documented define-param-expander public interface.
http://www.kylheku.com/cgit/txr/tree/share/txr/stdlib/keyparams.tl http://www.kylheku.com/cgit/txr/tree/share/txr/stdlib/keypar...
This is possible because the parameter macro can introduce identifiers into the scope of the function, and rewrite the parameter list.