On Mon, Feb 15, 2021 at 09:29:45AM -0800, Guido van Rossum wrote:
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'? [...]
I think that the desire probably comes from thinking of short mathematical functions where the body is a simple expression, like in maths: def f(x): return 3*(x**2) - 2*x + 4 is kinda clunky and not very maths-like compared to: f(x) -> 3*(x**2) - 2*x + 4 which is suggestive of function notation: f : ℝ -> ℝ, f(x) = 3*(x**2) - 2*x + 4 If you've used modern Computer Algebra System calculators, they often have similar notation: # Texas Instruments Nspire 3⋅x² − 2⋅x + 4 -> y (except they have a proper arrow too, not just ASCII hyphen greater than). So there is definitely some aesthetic advantage to the arrow if you're used to maths notation, and if Python had it, I'd use it. But it doesn't scale up to multi-statement functions, and doesn't bring any new functionality into the language, so I'm not convinced that its worth adding as a mere synonym for def or lambda or both. -- Steve