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

Yanghao Hua yanghao.py at gmail.com
Fri May 24 09:05:16 EDT 2019


On Fri, May 24, 2019 at 12:29 PM Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>
> Yanghao Hua wrote:
> > I have explained the problem of use
> > descriptors in previous replies, where you cannot have a local signal,
> > e.g. obj.signal = thing # works, but local_signal = thing # doesn't
> > work.
>
> Maybe you could do something like:
>
>     local = Signals()
>     local.signal1 = ...
>     local.signal2 = ...

In structure design ... and especially when you design a hardware that
is meant to be automatically converted into verilog or even logic
gates, I personally would really want to have a one-to-one
relationship of the python-objects vs the actual hardware structures.
The granularity is at signal/bit level. This is why I really think
giving a special assignment in python which users could override is
really helpful, rather than having to have this kind of special case:
if you do "self.abc = thing" descriptor mechanism is invoked, but the
very next line if you do "abc = thing" ... nothing will happen. This
special case can be completely removed and having a much better
conceptual consistency if the "<==" assignment operator always behaves
the same, doesn't matter if it is "self.abc <== thing" or "abc <==
thing".


More information about the Python-ideas mailing list