From: "Michael W. Ryder" <_mwryder@...> Date: 2007-05-25T09:45:05+09:00 Subject: Re: Introducing the "it" keyword Greg Fodor wrote: >> This break in concentration can be a real killer in finding obscure bugs. >> My proposal also suffers from some of this problem but as it is >> "inherited" from regular expressions it may be easier to figure out. >> > I understand these concerns. The pipes are just sugar, it seems like > it > would be a small learning curve to me, but here are a few other ideas: > > puts it if (x + y) * (it = (a - b)) < 10 > puts it if (x + y) * ((a - b) as_it) < 10 > puts it if (x + y) * ((a - b)) < 10 > > It's not quite convincing that having an explicit relationship between > it => pipes, once learned, is more difficult to read/parse in your > head than scanning parentheses to figure out which are being used > as storage and which are not. (And if you said $8, which one is > actually > $8 and not $7! :)) > > When I first learned Ruby, reading: > > return x if x < 5 > > Was really counterintuitive at first cause my brain was used to > thinking > "if I see 'return', it's going to return if I got to that line in the > code." I had to unlearn that assumption, and read the full line > checking > for the trailing condition. > As I have been programming in Business Basic for over 25 years I am used to seeing statements like: IF A$="" RETURN so I didn't have any problems with conditional returns. > I see that mental leap as being many times more difficult to learn > than > associating an expression wrapped in pipes (or other sugar) with the > 'it' > keyword. > > Although, I'll grant that if there is a solution that functionally > meets > my list that uses idioms from another domain like regular expressions > it > might be a good contender. Maybe you can explain more about the flags > thing with an example to see how it feels vs. the pipes approach? > If you had a statement like : puts $1 if (?:x + y) + (z * 2) < 10, then the program would print z * 2 if the expression evaluated to less than 10. The ?: flag tells the parser to not store the value of x + y.