From: Charles Hixson Date: 2004-10-14T04:46:46+09:00 Subject: Re: Ruby Directions (was Re: quality of error messages) David A. Black wrote: >Hi -- > >... > >I think of a range as kind of a fact. For example: (0..10) is "the >fact of being between 0 and 10, inclusive". In which case, changing >*that fact* -- e.g., having "the fact of being between 0 and 10" >*itself* become "the fact of being between 6 and 12" -- makes no >sense. I guess I think of ranges almost more like numbers; it would >make sense to me if (0..10) were literally the same object everywhere >it appeared. > >Anyway, all very speculative, but kind of interesting (to me at least >:-) > >David > I tend to think of ranges being rather like the bounds on a definite integral (not that I ever liked those...). Someone else anaogized them to a bounded arithmetic series (quite reasonable). There's all the theory you could want, if you just pick the right analogy. (An arithmetic series wouldn't include the space between the members, and integral would...but both of those include the end-point.) Personally I feel that an arithmetic series representation would be the best analogy (i.e., the most useful one), and that there are good practical grounds for NOT including the end point (index 0 is the 1st element of an array...so a range of 0..length is quite useful, provided the end point isn't included). But if it's an arithmetic series then the spaces between the points shouldn't be considered to be a part of the series. OTOH, it's just a LOT easier to check if 0 <= i < length than it is to compare for each member, and the main use is as array indicies, which are integer. I think the built-in parts of the language need to work together smoothly, and the current range does that properly and efficiently. Intervals (i.e., ranges with a constant increment of non-unity) would be an occasionally useful extension that would assist in working with n-dimensioned arrays (not matricies). The more generalized forms should be defined in (library?) classes. (Should Ruby come with "batteries included"? The decision seems to be no, use ruby-gems or the rpa. That works for me. But they should also be available on CD for those without an internet connection. A large tarball would suffice, so that you'd just need to find someone who HAD an internet connection and a CD burner.)