[Python-ideas] Operator as first class citizens -- like in scala -- or yet another new operator?

Greg Ewing greg.ewing at canterbury.ac.nz
Wed May 29 18:50:05 EDT 2019


Steven D'Aprano wrote:
> Yanghao Hua wants to customise the behaviour of assignment. I believe 
> that he wants to emulate the behaviour of some hardware description 
> languages, where the equals sign = doesn't mean assignment (if I have 
> understood correctly, which I may not have), but Something Else.

Maybe I can help a bit here. I don't have a deep knowledge of HDLs. but
from what I gather, they typically have two *different* assignment-like
operations. One of them is like assignment in a functional language,
where you're defining a signal as a function of other existing signals.
This corresponds to combinatorial logic in hardware. Python's existing
assigment is fine for this, I think.

The other represents updating a signal when some event occurs, such
as a clock transition. In hardware terms, it corresponds to changing
the state of a flip-flop. The OP wants a new operator and associated
dunder method to represent this operation. He doesn't want to override
normal assignment.

-- 
Greg



More information about the Python-ideas mailing list