From: gga Date: 2005-10-22T21:47:05+09:00 Subject: Re: A comparison by example of keyword argument styles Yukihiro Matsumoto ha escrito: > Hi, > > In message "Re: A comparison by example of keyword argument styles" > on Sat, 22 Oct 2005 03:08:19 +0900, Brian Mitchell writes: > > |Matz, are there any patches that implement your proposal yet? > > Not yet. The behavior was fixed on a night before the keynote. It is > much easier to implement than one in Sydney though. > > matz. One question. Why this complexity in syntax? Why the strange and very confusing ':' as the syntax delimiter in both function definition and, worse, parameter passing? Sorry, but this just feels so complicated to me and seems more something thought with ruby's parser in mind, not the user. What's wrong with '=' and avoiding defining explicit parameters in the parameter definition. Compare everything that was proposed with python's simplicity and elegance: # this is something akin to ruby's: def f(*args) def f2(a, b, c, *d): print a, b, c, d # and this is akin to ruby's: def f(arg={}) def f(a, b, c='xxx', **d): print a, b, c, d # --------------- f(1,2,3) # => 1 2 3 {} f(a=4, b=5, c=8) # => 4 5 8 {} f(3, b=5, c=8) # => 3 5 8 {} f(b=5, 3) # SyntaxError: non-keyword arg after keyword arg f(1,2,3, x="hello") # => 1 2 3 {'x' : "hello"} f(1,2) # => 1 2 xxx {} f2(1,2, 3, "hello", "a", "c") # => 1 2 3 ( 'hello', 'a', 'c') There's a lot of things I don't like in python, but how functions are defined is definitively one of the strongest things in the language. As you can see above, things are much simpler. No need to use any special syntax for named parameters in the function definition and the use of '=' is a heck of a lot more clear than : or =>. Both array and hash syntaxes for extra parameters are also accounted for.