[...]
But if we could expand the proposal to allow both anonymous and named functions, that would seem like a fantastic idea to me.
Anonymous function syntax:
(x,y)->x+y
Named function syntax:
f(x,y)->x+y
Proposals like this always baffle me. Python already has both anonymous and named functions. They are spelled with 'lambda' and 'def', respectively. What good would it do us to create an alternate spelling for 'def'?
Thanks for responding. I don't want to derail this discussion especially since I've brought it up in the last several months and didn't get anywhere on it.
To answer the question though: I think it would really open up python to a whole group of people are find the idea of "programming" too intimidating but could benefit from it immensely. This could happen if writing a function was made more similar to what they already KNOW how to write (handwritten math).
A common thing I hear from colleagues is "I'm not a developer, I'm not a programmer, I'm an engineer", and seeing this just intimidates people:
lambda x,y: (x**2+y**2)**0.5
def
hypotenuse(x,y):
(x**2+y**2)**0.5
Allowing short one-line functions to be spelled something like this would be more friendly because it looks so familiar, nearly identical to a handwritten mathematical equation:
hypotenuse(x,y) => (x**2+y**2)**0.5
Anyway I've offered up this desire to this list before and for the most part people haven't been very receptive, so I won't belabor it. But I thought I'd bring it up again in this context since this:
f(x,y) => x+y
...and this:
(x,y) => x+y
...would be SO CLOSE to each other.
You could also write this, I suppose:
hypotenuse = (x,y) => (x**2+y**2)**0.5
But that isn't any better for the casually programming engineer than lambda or def, to be honest.