I have my own preference, and have so far found arguments to the contrary unsatisfying because they are usually based on previous use of parens in other languages. (The most interesting suggestion I've heard is to use the parens to indicate if the return value of the method is useful or not. That is, whether a method is intended as a statement or an expression.)
I'm truly puzzled when people get their back up at the suggestion that their style preference is based on bias obtained from previous exposure to other language, conscious or not. I don't think too many people are deliberately thinking, "I want to make this look like [C|Java|Perl|PHP]", but surely there is *some* bias based on experience.
I agree there is some bias based on experience, as I went through
a phase about 18 years ago as a C programmer, deliberately
memorizing the operator precedence table and taking small delight
in being able to write expressions devoid of any parens except
those strictly necessary to the parser.
Note, also, that my first language was Forth, which I programmed
in for seven years--initially as a hobbyist, then professionally--
before I learned C.
Forth doesn't need parens for anything... ( they're comment delims. )
However, I'm not sure my Forth experience played a role in my
temporary dalliance with extreme paren minimalism in C. At the
time, I felt memorizing the operator precedence table and making
use of that knowledge by minimizing use of parens was sort of a
natural course to take for someone intent on mastering the
language.
Eventually one of my co-workers told me he had trouble reading
my code. Initially my (private) reaction was, this guy isn't
serious about his craft! He really ought to learn the language.
Thankfully I got past that phase eventually.
My current bias based on experience is that when reading code,
my brain does frequently prefer more parens than are strictly
necessary to the parser.
Example from earlier post:
For example, i find the following irritating and bad style:
===
def initialize foo, bar, batz = {}, &block
#(vs.)
def initialize( foo, bar, batz = {}, &block )
I find the second irritating because those parens are sooo
superfluous.
If I could have participated in this thread eighteen years ago I
would almost certainly have been in the superfluous==suboptimal
camp.
Nowadays, my brain finds the latter declaration with the parens,
more restful to the eye than the former.
It's easier for me to see the structure at-a-glance in the latter....
I realize this is necessarily very subjective. But my point is
just that the strictly minimal syntax required to satisfy the
parser is no longer an important criterion to me when I'm
writing code I want to be easy for me(*) to read.
*(((and apparently my poor co-workers))) <grin>
Regards,
Bill
···
From: "James Britt" <james.britt@gmail.com>
2009/2/18 Robert Dober <robert.dober@gmail.com>:
On Wed, Feb 18, 2009 at 9:48 AM, Florian Gilcher <flo@andersground.net> wrote: