Saturday, March 13, 2010
Parentheses (singular, Parenthesis)—sometimes called Round Brackets, Curved Brackets, Oval Brackets, or just Brackets, or, colloquially, Parens.
Contain material that could be omitted without destroying or altering the meaning of a sentence.
I think the above definition, must be considered when discussing about the non mandatory Parentheses use in Ruby.
On many discussion groups, people are questioning Matz’s option to not make the use of parentheses mandatory in Ruby Language, mostly around Ruby methods parameters.
Apparently this decision is becoming stronger.
If you run the following piece of code in Ruby 1.8.6, you will get a warning:
p Array.new 3, 1
ptest01.rb:1: warning: parenthesize argument(s) for future version
The same occurs with this one:
p Array.new (3+1), 1
ptest02.rb:1: warning: don't put space before argument parentheses
But if you run them in Ruby 1.9.1 they will pass with no warnings.
Do you really think it would be better this way?
When developing an application I like to put myself in the user’s shoes.
As a user of a reading text (program), I would like to read it easily.
Some times the absence of a rule is not that good.
But the strict use of a rule could be bad as well.
I have this little example:
I can say Matz is right to keep parentheses optional in Ruby, leaving to users the final decision on its usage.