Yanghao Hua wrote:
Did Guido say "user defined syntax" or "user defined operator"?
> ... for me defining new operator is different

To my mind it's not that much different. A reader encountering an
unfamiliar operator is pretty much faced with a new piece of
syntax to learn. Its spelling gives little to no clue as to its
meaning, it precedence in relation to other operators is not
obvious, etc.

The way scala allows user to define new operator is
really elegant,

There are some differences between Python and Scala that present
practical difficulties here. Some kind of declaration would be
needed to define its arity, precedence and corresponding dunder
method. This is no problem in Scala because it analyses imported
code at compile time. But the Python compiler only sees the module
being compiled, so it has no ability to import these kinds of
declarations from another module.

Plus, the way the parser works would probably have to be
completely redesigned.

So anyone suggesting user-defined operators be added to Python
has to both convince the community that it's a good idea in the
first place, and come up with solutions to all the technical
problems.

--
Greg
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to