From: Markus Date: 2004-10-05T23:33:48+09:00 Subject: Re: [RCR] New [] Semantics If I ever get past the parse.y hurdles, I plan to look at this. I think it's because ranges are actually a conflation of at least four ideas: * ranges of Comparable objects, with the low less than the high, in which case <=> gives a quick member test * arcs of demi-circular array subscripts, where negative values "count back" from the end * Sets of discreet values than fall within one of the above * Arbitrary "starting" and "ending" tests but I suspect this is not an exhaustive list. -- Markus On Tue, 2004-10-05 at 02:19, trans. (T. Onoma) wrote: > On Tuesday 05 October 2004 01:25 am, Markus wrote: > > Typically, the versions of ruby I produce in these experiments are > > killed by angry villages before they can show their essential > > kindheartedness. But I still hope. > > I occurs to me that the angry villagers might be confused. The example of the > never ending > > (0..(10.0/0)).member?(4) > > comes to mind. Why would this be an infinite loop? It must be trying to > generate the list before looking to see if 4 is in it (?) Are these ranges > that stupid? Even so, if it used succ to test this then it would take a while > to find out: > > time ruby -e '(0..1000000000).member?(999999999)' > > real 7m10.971s > user 6m56.150s > sys 0m0.617s > > Yuk. But there is nothing one can do about it as long as one depends on #succ. > I suppose it's awfully clever and OOP and all to have any object supporting > <=> and succ work with ranges, but I wonder how much use they get outside of > numbers and occasional character ranges. In other words perhaps succ isn;t > the way to go (or perhaps a fallback) and a simple increment/decrement in the > Range itself would be more usable --then the above 7 minutes would be about 7 > milliseconds. > > T.