> On 24 May 2019, at 22:11, Yanghao Hua <yanghao...@gmail.com> wrote:
>
>> On Fri, May 24, 2019 at 3:27 PM Ricky Teachey <ri...@teachey.org> wrote:
>> This seems like a hurdle you're going to have trouble passing... especially
>> given that all the functionality that is required can be provided using
>> existing descriptor behavior. You will need to pretty concretely demonstrate
>> why the special handling of signals in assignment (no matter which operator
>> is the operator of choice) is something the language at large really needs,
>> and why descriptors aren't sufficient.
>
> Just a quick example, suppose you have a class A and class B
> representing two circuit blocks, where in class C you want instantiate
> A() and B() and connecting them together. Please do let me know if you
> could have a more reasonable way of representation to make it working.
> class A:
> def __init__(self, output):
> self.output = output
> def process(self):
> self.output = 5 # !!! this does not work for descriptors passed in
> # self.c_self.signal = 5 # this might work, but what the heck really?!
>
> class C:
> signal = Signal()
> def __init__(self):
> a = A(output=self.signal)
> # a = A(output=self) # it is only possible for signal to work
> if you pass C's self into a ...
> b = B(input=self.signal)
> # !!! This does not work !!!
>
> Instead, a much more natural way of doing it is:
> class A:
> def __init__(self, output):
> self.output = output
> def process(self):
> self.output <== 5 # this always works!
>
> class C:
> def __init__(self):
> signal = Signal()
> a = A(output=signal)
> b = B(input=signal) # this feels much better, isn't it?
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
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?
/ Anders
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/