From: Charles Hixson Date: 2005-06-02T07:42:38+09:00 Subject: Re: ternary operator confusion ES wrote: >Le 1/6/2005, "Eric Mahurin" a �crit: > > >>--- "Marcel Molina Jr." wrote: >> >> >> >>>On Thu, Jun 02, 2005 at 01:40:23AM +0900, Phrogz wrote: >>> >>> >>>>true ? a.push(1) : a.push(2) >>>> >>>> >>>i suspect this could have been just a contrived example but >>>you could also >>>do: >>> >>>a.push true ? 1 : 2 >>> >>> >>I wish Ruby didn't make the () optional when passing args >>(probably from Perl which wanted to be like shells/tcl/lisp >>where command/function and arguments are space separated). >> >>When you don't put the () in, the precendence can get confusing >>and you arbitrarily prevent the first arg to start with a "(" >>(otherwise it will treat that "(" as what starts the argument >>list). >> >>Why do people feel the need to drop the ()? I didn't like it >>in Perl and I don't like it in Ruby. Do people just want >>something that is kind of like shell syntax? >> >> > >Less typing, uniform access, etc. Good news is that if one does >want to use parens, one is welcome to not do so. > >E > >-- >template >void quack(duck& d) { d.quack(); } > > > > Uniform access could have been achieved if only () was made optional. (A good choice in my mind.) OTOH, I'm not that happy with optional parenthesis where the parameters are required. To me that feels like a bad design choice. (And with some type faces the difference between (stuff) and {stuff} isn't all that obvious. But that's a font problem...mainly.)