[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 07:40:34 EDT 2019


On Sat, May 25, 2019 at 11:24 AM Anders Hovmöller <boxed at killingar.net> wrote:
> process() in A could look like:
>
> self.send(output=5)
>
> To me that looks OK, and scales nicely with multiple outputs:
>
> self.send(a=5, b=3)
>
> send() is implemented simply as
>
> def send(self, **kwargs):
>     for k, v in kwargs.items():
>         signal = self.signals[k]
>         signal.c_self.output = v

I am sure there are probably a hundred different ways to do this, and
all of them may seem nice from a software perspective. But this is
really not simpler than existing HDLs which just does signal = 5. One
of the reason a lot of people using python is that you can use less
chars to represent your ideas precisely, e.g. instead of doing xyz =
obj.bar() you can do xyz = obj.bar and making bar as a descriptor, why
do we do this at all? because we want to make bar looks like a
variable instead of a method and in many cases it present the idea
better. So is @ and @=, so is meta class, so is decorators ... and it
goes on and on. The intention, is not to have a way to do it, the
intention, is to have a equally good way to do it as in traditional
HDLs.

>
> Or something. I'm not sure about the details since I don't understand the example you give. It's pretty abstract and vague. Just a simple example of how to use A with a print() and the expected output of said print would help?

the example is already to its bare minimum, which part is vague? I can
elaborate if you could be more specific.


More information about the Python-ideas mailing list