2 ms·
In TXR Lisp, you can delegate with struct clause macros :delegate and :mass-delegate: https://www.nongnu.org/txr/txr-manpage.html#N-92252A14 https://www.nongnu
by kazinator 3y ago
In TXR Lisp, you can delegate with struct clause macros :delegate and :mass-delegate:
https://www.nongnu.org/txr/txr-manpage.html#N-92252A14 https://www.nongnu.org/txr/txr-manpage.html#N-92252A14
https://www.nongnu.org/txr/txr-manpage.html#N-5F56EB59 https://www.nongnu.org/txr/txr-manpage.html#N-5F56EB59
These are themselves written via define-struct-clause, which provides a macro mechanism for writing new kinds of clauses that can appear in a defstruct:
https://www.nongnu.org/txr/txr-manpage.html#N-91BFF63B https://www.nongnu.org/txr/txr-manpage.html#N-91BFF63B
define-struct-clause itself provides a kind of alternative to manually doing composition and inheritance: you just define some new clauses to do whatever is necessary and use them in the target classes.
A custom clause can cause the target class to inherit bases. What makes that possible is that inheritance is not only expressed using (defstruct duck (animal ...)) but alternatively via a an (:inherit ...) clause. Thus clause macros can generate (:inherit ...), thereby injecting bases.