Karnickel: AST Macros for Python
bitbucket.org
bitbucket.org
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?
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.