[Python-ideas] Allow additional separator character in variables

Chris Angelico rosuav at gmail.com
Sun Nov 19 19:20:01 EST 2017


On Mon, Nov 20, 2017 at 11:01 AM, Mikhail V <mikhailwas at gmail.com> wrote:
> 1. The future versions of syntax, ideally, must allow ONLY minus U2212 for
> the minus operator, and allow hyphens 002D in identifiers. Since it is
> impossible
> to the current moment, I must think out the least painful transition.

The least painful transition is to devise an entirely new language,
one that is built around whatever rules you like. That way, there's no
backward compatibility problem - you pick a new file extension, a new
executable name, etc, etc, and nobody gets confused. Of course, since
actually building a cross-platform language interpreter is a ton of
work, and getting an ecosystem of libraries is even more work, you'll
want to make your language compile to Python, but *in your source
code* you can use whatever symbols you want.

Since you want U+2212 for subtraction, you probably want to use a few
other non-ASCII operators too. U+2044 FRACTION SLASH presents itself
as a viable way to create a fractions.Fraction literal. Instead of *
and @ for multiplication, you could have U+00D7 and... uhh, I'm not a
mathematician, but I'm sure there's an appropriate character.

For the most part, you'd have code that is trivially transformable to
and from Python. Start by writing the "my language to Python"
translator (it can throw away comments and stuff, the Python code
should be considered "object code" rather than "source code"), and
then look into the reverse transformation for the benefit of people
trying to learn your language.

As long as you don't actually call your language "Python", you're free
to do what you like without worrying about compatibility etc.

ChrisA


More information about the Python-ideas mailing list