On 22/05/2019 13:29, Yanghao Hua wrote:
Problem is python do not allow you to define new operators in the
language itself, except those pre-defined you can modify their
behavior. Even in case, if python would have been able to allow me to
redefine the behavior of "=", e.g. by checking if the left hand side
has a method (e.g. __assign__) to override the default behavior of the
equal sign, I would be 100% happy already :) I have looked into all
the existing operators that python supports which looks like an
"assignment", none has been fallen in love with me. The example in
Chisel w/ Scala is: they defined quite a few operators: ":=" for
signal assignment, "<>" for bulk signal connections etc. And you can
keep inventing new operators with which your design can look really
elegant.

A note of caution: your design can look really elegant *as long as you know what your new operators mean*. If you don't, it's looks like incomprehensible noise. I have had far too many bad experiences with "clever" C++ with redefined operators to assume that "elegant" and "obvious" go hand in hand.

If you really must prat around with redefining assignment, make the relevant attribute a property.

--
Rhodri James *-* Kynesim Ltd
_______________________________________________
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