On Sun, Feb 14, 2021 at 12:47:30AM +0300, Paul Sokolovsky wrote: > Hello, > > On Sat, 13 Feb 2021 16:25:24 -0500 > Cade Brown <brown.c...@gmail.com> wrote: > > > In my humble opinion, arrows should be '->' instead of '=>'. It always > > annoys me when languages use that symbol > > That's unlikely, as was discussed in this thread previously: > > a) JavaScript already uses "=>", and it doesn't make sense to be > different just for the purpose of being different. That will only > confuse people.
It's not being different for the sake of being different. It's being different because Javascript gets it wrong, and we should get it right. *semi-wink* I wouldn't worry about being inconsistent with Javascript. We are already inconsistent with Javascript in many, many, many ways. One more is no big deal. Other popular and influential languages include: Maple, CoffeeScript, Groovy and Erlang use "->" # Maple multiply:= (a, b) -> a * b; # Coffeescript multiply = (x, y) -> x * y # Groovy def multiply = { x, y -> x * y } # Erlang multiply(X,Y) -> X * Y. Dart uses "=>" multiply(x, y) => x * y; Haskell, Ela and Elm all use "=" for named functions and "->" for anonymous functions: multiply x y = x * y \x y -> x * y Julia is similar to Haskell: multiply(a, b) = a * b (a, b) -> a * b Python uses ":" *wink* lambda a, b: a * b R uses a space: multiply = function(a,b) a*b More examples here: http://www.rosettacode.org/wiki/Function_definition The question we should be asking is not so much how popular Javascript is in absolute terms, but: - how many people coming to Python will be familiar with Javascript as opposed to R, Julia, Maple, etc, or no language at all? - given how many other things they will have to learn that is different, is one comparatively rarely used feature more that much of a burden? > b) Python already uses "->" for function return *type*. And there's > idea to generalize it to *function type* in general. E.g. a function > "(a, b) => a + b" can have type "(int, int) -> int". This supports the idea of using "->" as the "return operator". In annotations, it annotates the return *type* and in function bodies it marks the return *value*. (a:int, b:int -> int) -> a*b Why have two different "return operators"? That can only lead to confusion: # Which of these are correct? (a, b) -> a*b (a, b) => a*b def func(a, b) -> Spam: pass def func(a, b) => Spam: pass # and if arrow functions allow annotations, it's even worse! (a, b -> Type) -> a*b (a, b => Type) -> a*b (a, b -> Type) => a*b (a, b => Type) => a*b Let's keep it nice and simple. We already use "->" as the "return operator", so let's use it for arrow functions too. (All of this assumes that arrow functions are justified in the first place.) -- Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/SV6RE233SWJQOYRYF3VENUAHTQYSRPCE/ Code of Conduct: http://python.org/psf/codeofconduct/