B
Bill Kelly
[Sorry, hit some control key and sent my previous message before
completing it.]
"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 find these reasons sufficient and non-arbitrary.
But we do get disagreement among programmers as to the *degree*
to which parens ought to be used to clarify operator precedence.
The same kind of disagreement happens in C with regard to
whether and when to use braces when the body of a conditional
is a single statement.
if (foo)
bar();
else
baz();
if (foo) {
bar();
}
else {
baz();
}
if (xyzzy)
if (foo)
bar();
else
baz();
if (xyzzy) {
if (foo)
bar();
else
baz();
}
if (xyzzy) {
if (foo) {
bar();
}
else {
baz();
}
}
Some programmers argue for one extreme or the other, while others
take some middle ground.
And some change their minds over the years, maybe multiple times.
*shrug*
Here's some more ruby:
http://codefluency.com/articles/2008/08/17/arrow-lambdas-a-ruby-1-9-vignette/
The following is a completely legal _single_ lambda being immediately invoked
-> a = 1, b = 2, c, &d ; e { e = d.(a * b * c); e + 1 }.(3) { |p| p * 4 }
...and with parens:
-> (a = 1, b = 2, c, &d ; e) { e = d.(a * b * c); e + 1 }.(3) { |p| p * 4 }
They're both funky, but the latter is clearer to me.
Anyway, really I don't think it matters whether it's function
declarations, operator precedence, or (in the case of the C
example) where to add braces...
Seems we just have individual programmers, with their own sense
of style, each (hopefully) trying to make their code as readable
as possible.
De gustibus, and all that....
Regards,
Bill
completing it.]
From: "Juan Zanos said:One of the things that confuses this discussion is that some people
are talking about the use of parentheses with regard to operator
precedence rules and others are discussing far more arbitrary and
questionable usages such as in declaring and calling functions. I
think it's telling that such a seemingly minor complexity is cause
for confusion.
Again:
"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 find these reasons sufficient and non-arbitrary.
I doubt you'll get much disagreement that operator precedence rules
for c (or Ruby) are complex enough that there are cases where the use
of parentheses simplifies reading. That doesn't seem to be
something anyone is questioning.
But we do get disagreement among programmers as to the *degree*
to which parens ought to be used to clarify operator precedence.
The same kind of disagreement happens in C with regard to
whether and when to use braces when the body of a conditional
is a single statement.
if (foo)
bar();
else
baz();
if (foo) {
bar();
}
else {
baz();
}
if (xyzzy)
if (foo)
bar();
else
baz();
if (xyzzy) {
if (foo)
bar();
else
baz();
}
if (xyzzy) {
if (foo) {
bar();
}
else {
baz();
}
}
Some programmers argue for one extreme or the other, while others
take some middle ground.
And some change their minds over the years, maybe multiple times.
*shrug*
Here's some more ruby:
http://codefluency.com/articles/2008/08/17/arrow-lambdas-a-ruby-1-9-vignette/
The following is a completely legal _single_ lambda being immediately invoked
-> a = 1, b = 2, c, &d ; e { e = d.(a * b * c); e + 1 }.(3) { |p| p * 4 }
...and with parens:
-> (a = 1, b = 2, c, &d ; e) { e = d.(a * b * c); e + 1 }.(3) { |p| p * 4 }
They're both funky, but the latter is clearer to me.
Anyway, really I don't think it matters whether it's function
declarations, operator precedence, or (in the case of the C
example) where to add braces...
Seems we just have individual programmers, with their own sense
of style, each (hopefully) trying to make their code as readable
as possible.
De gustibus, and all that....
Regards,
Bill