[Python-ideas] Python dialect that compiles into python

Stephan Houben stephanh42 at gmail.com
Tue Sep 11 06:24:27 EDT 2018

Op di 11 sep. 2018 om 10:42 schreef Brice Parent <contact at brice.xyz>:

> Le 11/09/2018 à 02:15, Abe Dillon a écrit :
> [Steven D'Aprano]
>> It would be great for non-C coders to be able to prototype proposed
>> syntax changes to get a feel for what works and what doesn't.
> I think it would be great in general for the community to be able to try
> out ideas and mull things over.
> If there was something like a Python Feature Index (PyFI) and you could
> install mods to the language,
> it would allow people to try out ideas before rejecting them or
> incorporating them into the language
> (or putting them on hold until someone suggests a better implementation).
> That would be an almost-Python to Python transpiler, I love it! It would
> surely help a lot to explain and try out new ideas, as well as for domain
> specific needs. And having an index of those features could help a lot.
> It would surely also help a lot with backward compatibility of new
> functionalities. Someone who would want to use a Python 3.9 functionality
> in 3.8 (whatever his reasons) could use a shim from the index. Such shim
> wouldn't have to be as optimal or fast as the version that would be used in
> 3.9, but it could be functionally equivalent to it.
For what it's worth, the Ocaml community has something like that: Campl5

Despite the name "preprocessor" this actually communicates with the Ocaml
compiler proper through an AST.
So you get proper source code location, etc.

I think you could actually already hack something like this in Python today,
by creating custom import hooks, which then run your own compile step on a
file, which produces an AST, which
is then passed to compile().

However keeping your custom Python++ parser in sync with Python is probably
a pain.

> I'm just a bit afraid of the popularity that some of these experiments
> could get (like `from __future__ import braces` -> No problem!) and the
> pressure that could be made upon core devs to push the most popular changes
> into Python (popularity not being equivalent to sanity for the language and
> its future. There are many devs that want to code in one language the same
> way they do in others, which is often wrong, or at least not optimal).

I fully expect the core devs to resist such pressure, especially for the
braces ;-)


> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180911/08cd3112/attachment.html>

More information about the Python-ideas mailing list