From: Hugh Sasse Staff Elec Eng Date: 2005-02-01T00:24:18+09:00 Subject: Re: nil question On Mon, 31 Jan 2005, William James wrote: > Austin Ziegler wrote >> you can also do: >> >> puts "yes" if x.between?(-5, 9) >> puts "yes" if (-5..9).include?(x) > > But that's not as readable as -5 < x < 9, which is how it is written > for humans in algebra. > > In Icon, comparisons succeed or fail, they don't return true or false. That's true for all statements in Icon. I > So in Icon, a < x < b means exactly what it does in algebra. So effectively you get two things from a comparison: success/failure and result-if-success I think that you'd need to import this behaviour into Ruby -- a rather dramatic change -- for this to work as nicely as it does in Icon. I left my proposal on line; the only other way I can think to do this is have the parser handle comparison expressions at the priority it does now, but do the grouping in the way you describe for comparisons only. Again, that is a significant modification to the parser. That way the whole expresion would return true or false as now and the right-hand-sides would only be kept internally during evaluation. This layer of complexity may hinder debugging, however. http://www.eng.cse.dmu.ac.uk/~hgs/ruby/comparisons.html so you can see what I wrote. > > Matz and many Ruby gurus think that Ruby incorporates the best > features of preceding languages (e.g., Awk, Perl, Python, Smalltalk). > But how many of these people ever used Icon? > Icon, and now Unicon, has some excellent features, but I hope they don't take too many of them: I've still not made the transition to the goal directed way of thinking, and find it hard to write code that uses it well. Suspend is nice, but Ruby has generators now. Some search problems are particularly easy to express in a goal directed way, so I'd like to see a module implementing that, for such cases, but I find the present programming model easier for most apps. > Hugh