From: Trans Date: 2005-11-18T13:27:18+09:00 Subject: Re: Keyword arguments like grandma makes 'em rcoder wrote: > > I'm not sure that's neccessarily true. Yes it is true for 'and' and > > 'or' and a few others, but 'alias', 'begin' and other aren't really > > useful in the context of arguments, so they could still be used. > > And how, exactly, would you decide which keywords were and weren't > useful in method argument context, given that just about everything > aside from basic assignment in Ruby is based on method calls? Something > about that smells awfully Pythonic to me... Well, 'alias' isn't a method. In fact I think it should be gotten rid of. #alias_method is a method and thus is preferable. begin...end clauses aren't methods either and I don't see any good reason to ever make them so. Yet I point out #begin and #end are methods of MatchData. So I think these can be resused for keywords arugments witouht issue. if, case, until, loop, while, for: Except perhaps for 'for' I don't see these as much of a loss if they couldn't be used for keywords args. In fact 'if' and 'case' and 'while' I think make esspecially poor keywords anyway. OTOH, they are rarely used for return values anyway, and exponetially less so as direct method arguments. In fact I can't think of a single time I ever used a condition or loop construct as an argument. Sso that's the other possibility, and again not much a loss (if any) here either. > One of my favorite aspects of Ruby's syntax is that *every* syntactic > structure is an expression which returns a useful value. While you > might not want to have a full 'case' switch tree inside the arglist, > the syntax does not prohibit it. Well. That's not completely true. But it'ss certainly close. I think the not wanting a 'case' switch as an argument is pretty much universally desired. No one wants to read code like that --actaully we wouldn't have blocks if we wanted code like that. So prohibiting it I doubt anyone would even notice. > Making the overall syntax significantly more restrictive in order to > eliminate a single character sigil for keyword args (which, since most > methods require very few arguments, should be used only in the minority > of cases) is still a bad trade in my book. One sigil? When used once. In the course of an application one becomes thousands. Morevoer, it's not a bad trade at all when you also consider colon to colon syntax ugliness. > Of course, for people coming to Ruby via Rails, I can see the appeal of > making keyword args as easy to use as possible, since the Rails team > seems to have a real fetish for having single "do-it-all" methods that > dispatch based on an arbitrary number of optional keyword args. Perhaps a little overdone, but it's useful. I'm not coming from Rails BTW. I've been here awhile. T.