
July 10, 2020
12:41 p.m.
On Fri, Jul 10, 2020 at 08:23:09AM -0400, Ricky Teachey wrote:
My mind instantly went to the idea of using this syntax as a way write single line mathematical function definitions:
f[x, y] = x + y
This won't work, because the right hand side will be evaluated first. The above is legal syntax today, and roughly equivalent to: value = x + y index = (x, y) f.__setitem__(index, value) except of course no such local variables value and index are created. But you can see why that cannot be used to define a function: the right hand side is evaluated, and all your `__setitem__` method will see is the value of x + y, not the fact that it is "x + y". -- Steven