From: "Michael W. Ryder" <_mwryder@...> Date: 2007-05-31T15:40:16+09:00 Subject: Re: Introducing the "it" keyword Chad Perrin wrote: > On Thu, May 31, 2007 at 11:30:30AM +0900, Michael W. Ryder wrote: >> While I realize the Ruby is not C, I think that some of the style >> guidelines for C should still apply in Ruby. One of the ones that was >> very important was to make each statement do only one thing. Your >> example of setting a temporary variable to an amount on one line and >> then testing that variable on the second line is much easier to read, >> and understand, quickly than your statements like 'return %$ unless f(n) >> == x'. This becomes even more important when the test is even more >> convoluted such as checking for the position of a string in another >> string and returning if it is in a specific location. > > I'm afraid I must disagree. The only thing I find "unreadable" about > that is the complete lack of obvious association between %$ and the > source of the value it contains/labels. The composition of the > expression itself, such that the condition test is on the same line as > the rest of the action, produces absolutely zero difficulty for me. > The problem is when trying to maintain the code. Suppose you have to change the test and it changes what is referenced by %$x or $1 or whatever is used. Now you have to try and determine what you need to use for the return to get the correct value. I find that harder than having one line determine the test value and a separate line determining what is done with that value. As I am still maintaining code I wrote over 20 years ago I find that clear code is far better than clever. In the past when working with other peoples programs I often found that I had to remove large chunks of the code and replace it because the old code was not clear or maintainable. > I get the impression that you don't like the predicate conditional form > at all, then, and would rather it was stricken from the language. Yes? > I never said I wanted something stricken from the language. Much like any language I use I don't use all of the parts as there are usually more than one way to get the same results. When programming in C I didn't use all the obscure tricks to make one line programs but that didn't mean that I wanted those tricks removed from the language. In Ruby I have found that there are usually several ways to accomplish the same task and I choose to use those I can maintain, not those that will cause endless hours of time to figure out and maintain.