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

Yanghao Hua yanghao.py at gmail.com
Sat May 25 15:09:32 EDT 2019


On Sat, May 25, 2019 at 8:28 PM Terry Reedy <tjreedy at udel.edu> wrote:
>
> On 5/24/2019 4:25 PM, Yanghao Hua wrote:
> > On Fri, May 24, 2019 at 5:45 PM Terry Reedy <tjreedy at udel.edu> wrote:
> >> What I understand is that you are doing discrete-time hardware
> >> simulation and that you need a operator that will schedule future
> >> assigments to int-like objects.  Have you considered using '@' to do
> >> that?  int @ int-expression is currently invalid, so defining it will
> >> not interfere with other int operations.  What am I not understanding?
> >
> > I am not sure if I understood this. The intention is to e.g. assign a
> > signal with a value in a nature way, e.g. signal <== 5, are you saying
> > to replace <== with @?
>
> That is what i meant, but reading
>
>  > I really really would like either a equal sign
>
> suggests '@=' as a better alternative.  (I am not sure if the
> implementation would be equally easy or hard.)  How does 'signal @= 5' look?
>
> Either is pragmatic in that these exist since a few versions ago, and
> cannot interfere with existing integer expressions, rather than in the
> far very hypothetical future.
>
>  > not really intuitive though
>
> '@' means 'at' and you want to make the assignment 'at the next time
> mark' (or whatever you call it). This is more intuitive to me than
> seeing '@' as 'matrix-multiply' because 'matrix' contains 'at'.
>
> When we added @, it was known and intended that it could serve other
> then unknown uses.

@= has all the same issues like <<= or >>=, in that you are basically
sacrificing a well known number operation and force it to mean
something completely different. In previous examples I have shown that
HDLs are basically handling numbers, so <<=, >>=, |=, &=, +=, -=, %=,
*=, <<, >> all could be, and should be used directly to signals. I
admit this (@=) is a much rarer case, but why do we want to exclude
the possibility for a matrix of signals to multiply another matrix of
signals and assign the result to another matrix of signals? how does
this look like? X @= (X @ Y), where @= means signal assignment, and X
@= Y, does it mean signal assignment of Y to X, or does it mean X = X
@ Y? This simply causes a lot of confusions. I want a solution that is
impossible to cause any confusions. As @ and @= is built in python,
any one could be using it in all possible ways that is beyond our
imagine ... unless I have a way to make sure user cannot use @= as
matrix multiplication (which obviously I cannot), otherwise I am very
much de-motivated to use it to mean HDL signal assigns ...


More information about the Python-ideas mailing list