2 ms·
Couple of questions: 1. Can the macros execute code while expanding? 2. Is there any way to use gensyms? 3. In Common Lisp, the add-macro would probably use
by jpr 16y ago
Couple of questions:
1. Can the macros execute code while expanding?
2. Is there any way to use gensyms?
3. In Common Lisp, the add-macro would probably use quasiquote and unquote, like this:
(defmacro add (x y)
`(+ ,x ,y))
Is there any way to use quoting?
- mace 16y ago> 1. Can the macros execute code while expanding? Probably, since this 'expansion' occurs during runtime. > 2. Is there any way to use gensyms? Gensym-type functionality could probably be added. > 3. In Common Lisp, the add-macro would probably use quasiquote and unquote, like this: (defmacro add (x y) `(+ ,x ,y)) > Is there any way to use quoting? Not likely, since Python itself treats code and data differently. The main benefit is in creating new statements, expressions and blocks to allow for new abstractions. But this is not quite the same as Lisp macros.