[Python-ideas] A "local" pseudo-function
Greg Ewing
greg.ewing at canterbury.ac.nz
Sun Apr 29 01:02:18 EDT 2018
Tim Peters wrote:
> The points to using function-call-like syntax were already covered
> ("nothing syntactically new to learn there",
The trouble is that one usually expects "nothing syntactically
new" to imply "nothing semantically new" as well, which is very
far from the case here. So I think that not using *any* new
syntax would actually be hurting users rather than helping them.
If you really want to leverage existing knowledge, I'd suggest
something based on lambda:
let a = 3, b = 4: a + b
This can be easily explained as a shorthand for
(lambda a = 3, b = 4: a + b)()
except, of course, for the magic needed to make it DWIM in an if
or while statement. I'm still pretty uncomfortable about that.
--
Greg
More information about the Python-ideas
mailing list