From: Juan Zanos Date: 2009-02-19T23:57:24+09:00 Subject: Re: What are your favorite Ruby features? On 18 févr. 09, at 18:43, Bill Kelly wrote: > > From: "James Britt" >> >> 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. 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. 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. Cheers, Juan