dunossauro / dunossauro/live-de-python
[Sugestão] PEP 638 - Syntactic Macros
- Dominant language
- Python
- Stars
- 1.3k
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
# Source
[python.org/dev/peps/pep-0638/](https://www.python.org/dev/peps/pep-0638)
# Abstract
This PEP adds support for syntactic macros to Python. A macro is a compile-time function that transforms a part of the program to allow functionality that cannot be expressed cleanly in normal library code.
# Rationale
Python is both expressive and easy to learn; it is widely recognized as the easiest to learn widely-used programming language. However, it is not the most flexible. That title belongs to lisp.
Because lisp is homoiconic, meaning that lisp programs are lisp data-structures, lisp programs can be manipulated by lisp programs. Thus much of the language can be defined in itself.
We would like that ability in Python, without the many parentheses that characterize lisp. Fortunately, homoiconicity is not needed for a language to be able to manipulate itself, all that is needed is the ability to manipulate programs after parsing, but before translation to an executable form.
Python already has the components needed. The syntax tree of Python is available through the ast module. All that is needed is a marker to tell the compiler that a macro is present, and the ability for the compiler to callback into user code to manipulate the AST.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.