From: Juan Zanos Date: 2009-02-20T00:44:39+09:00 Subject: Re: What are your favorite Ruby features? On 19 févr. 09, at 10:21, David A. Black wrote: > This message is in MIME format. The first part should be > readable text, > while the remaining parts are likely unreadable without MIME- > aware tools. > Hi -- > > On Thu, 19 Feb 2009, Juan Zanos wrote: > >> >> 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 don't think there's any confusion, just (rather trivially, in the > overall scheme of things) different practices. > > > David > > -- > David A. Black / Ruby Power and Light, LLC > Ruby/Rails consulting & training: http://www.rubypal.com > Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) > > Ruby Training Atlanta! April 1-3, http://www.entp.com/training/ > atlanta09 I haven't heard any different practices with regard to parenthesis and operator precedence in this discussion. Am I wrong about this? And with regard to operator precedence it doesn't sound like there are any unique issues with Ruby. Well, other than the fact that you can create new operators with Ruby and you can't in most languages. But nobody has mentioned that feature. Cheers, Juan