From: gabriele renzi Date: 2003-11-18T18:37:16+09:00 Subject: Again, Rite explanation needed (keyword args and new hash syntax) Hi gurus and nubys, Again here to bother you :) Please note that I'm not here to start a flame. I actually want to understand matz' and dev/core choices, please excuse me if I sound rude. This is the supposed behaviour for kwd args: --- def f(a,b: 2 , **kwd) p [a,b,kwd] end f(1) #=> [1,2,{}] f(1,b:5) #=>[1,5,{}] f(1,b:5,c:6) #=>[1,5,{:c=>6}] --- I wonder: why we introduce the ':' syntax ? Why can't we call a kwd arg like f(1,b=5) ? I suppose this is to avoid conflicts with normal assignment.. but what's wrong with making go away the assignment in method calling? ? OTOH, why we have to define kwd args with f(a,b:2) instead of f(a,b=10) ? if f(a,b:10) cames in default argument with '=' actually become useless? I suppose matz refused the current keyword args syntax as it is found in python. I just wonder why :) (maybe just because we don't have a () operator?) PS btw the 'a: c' syntax for hash is really cool. I always hate to type 'a'=>b or :a=>b. PPS I'd love to see : and => unified as 'a=>b is the same that a: b and it works like hash[a]=b if var a is defined or like hash[:a]=b if a is not already defined' but I'm just dreaming,remeber: when *you* will write *your* language you'll follow *your* POLS. Too bad matz' logic is so obvious to me most of the time, this keeps me away from writing MyLang ;) PPPS literals, and method argument definition, are actually embedded micro languages. It seem normal to me that '{a=>b}' could work differently from 'a = b' (i.e. look if the var exist and act differently). Nobody expects a string literal or a regexp literal to work like the rest of the code. But we expect this from Arrays and Hashes (and somewy Ranges). This must mean something. Possibly that I need more coffe in the morning.