From: James Britt Date: 2009-02-19T02:30:08+09:00 Subject: Re: What are your favorite Ruby features? Florian Gilcher wrote: > > On Feb 17, 2009, at 9:30 PM, James Britt wrote: > >> David Masover wrote: >> Same here. I think of them as FGPs: Feel-good parentheses, used >> because they make people accustomed to C or Java feel more >> comfortable, though they do not contribute any real code value. > > > Thats a harsh statement for those that do actually like parantheses and > not because they are C//Java-Guys. It's simply an observation based on reasons people have given me when I try to understand what value the parens offer. It ends up being, "I'm used to them", or, "It looks weird without them", or, "I find it more readable." Basically, their absence makes some people uneasy; they feel better with them there, though they do not provide any information or programmatic value. I'm sure there are people who did not come to Ruby after using Java or C and still think the parens make the code easier to work with. I just haven't met them. :) > > For example, i find the following irritating and bad style: > > === > def initialize foo, bar, batz = {}, &block > #(vs.) > def initialize( foo, bar, batz = {}, &block ) > === > > I see the argument list as a tuple and I like it to resemble one. > Except you can't do this: def foo (my, tuple, arg); end > Also, i tend to brace long and unbalanced statements: > > === > var_foo_bar = (::Something::Somewhere::Object.new( > :foo => "bar" > ) > ) There *are* times when the parens may make the arg list more readable, but it ends up being a matter of taste, and that comes from exposure. The more people add the redundant parens, the more they see it as "right", and the more they do it. I prefer to omit whatever I can until I have a good reason not to. Maybe that good reason ends up being, "I'm making more stupid errors", and that's fine, but so far I've had fewer such errors without the parens than with them. I don't expect anyone is going to change their minds on this based on words alone, but it's interesting to see how preferences evolve. For example, in learning Haskell, I've come across a number of places that explain that while one can use parens in various places, the preferred style is to leave them out when possible. Different culture. -- James Britt www.happycamperstudios.com - Wicked Cool Coding www.jamesbritt.com - Playing with Better Toys www.ruby-doc.org - Ruby Help & Documentation www.rubystuff.com - The Ruby Store for Ruby Stuff