From: gabriele renzi Date: 2003-11-18T22:32:16+09:00 Subject: Re: Again, Rite explanation needed (keyword args and new hash syntax) il Tue, 18 Nov 2003 21:05:59 +0900, Michael Neumann ha scritto:: ? >> >> Why can't we call a kwd arg like >> f(1,b=5) > >b=5 is an expression and is allowed everywhere to appear. >With your suggestions, this would be no more true. ok, thanks, now I understand why b: a syntax is needed to call stuff. > >And you would not break any existent programs, e.g. > > f(line=gets, ...) > puts line > >would still work. well, we're breaking existing stuff anyway (block vars, class vars, constant lookup) taht's the point in a major release :) >> I suppose this is to avoid conflicts with normal assignment.. >> but what's wrong with making go away the assignment in method calling? >> ? > >Expression-orientedness. Any expression should be allowed, even the >following: ok, nice explanation thanks. >> OTOH, why we have to define kwd args with >> f(a,b:2) >> >> instead of >> f(a,b=10) > >Conflicts with default values when argument is ommited. > well, I don't see it as 'conflict' much like 'overlap' > >> if f(a,b:10) cames in default argument with '=' actually become >> useless? > >But b:10 is a keyword argument, whereas b=10 would be a numbered >argument (as in Python). well, I thinmk the two are unified in python (I may be wrong): >>> def f(a=1,b=10): .... print a .... print b .... >>> f(1) 1 10 >>> f(1,4) 1 4 >>> f(a=3,b=434) 3 434 > >The good thing with matz's keyword arguments is, that it will not break >existing applications. At the first moment, I didn't liked matz's idea, >but now, it think it's really cool. > I'm sure it's cool that's why I'm trying to understand it :)