In Common Lisp, it is relatively easy to create a macro-defining macro. For example, the following macro
(defmacro abbrev (short long) `(defmacro ,short (&rest args) `(,',long ,@args)))
is a macro-defining macro because it expands to another macro.
If now put
(abbrev def defun)
in our program, we can write def instead of defun whenever we define a new function. Of course, abbrev can be used for other things. For example, after
(abbrev /. lambda)
we can write (/. (x) (+ x 1)) instead of (lambda (x) (+ x 1)) . Nice. (For a detailed explanation of the abbreviation, see http://dunsmor.com/lisp/onlisp/onlisp_20.html )
Now my questions are:
- Can I write macro-defining macros in Racket?
- If I can, how to do it? (for example, how to write something similar to an
abbrev macro in Racket?)
source share