From: ahoward Date: 2003-02-12T04:20:21+09:00 Subject: Re: Range#length?!?!? On Wed, 12 Feb 2003, Yukihiro Matsumoto wrote: > Interesting. is that good, or bad? ;-) > But 'even this' never reaches 'works quickly' under the current > String#succ behavior. > > for x in 'even this' ... 'works quickly' > ... > end > > would be an infinite loop. thechnically so is for x in 0.0 ... 42.0 ... end just because one can designate the beginning and ending of range doesn't mean one MUST be able it iterate over it does it? (asking) i guess the question is WHAT a Range of strings is : * all possible comibnations between start and end * a linear (succ) progression between start and end it seems as if viewing the bytes (mulibytes) of a string as base 256 (or sizeof multibyte) digits would allow your example to iterater properly since semantically once you incremented 'even this' upto 'w\000\000\000\000\000\000\000\000\000\000\000\000\000\000' you could then begin incrementing only [1..-1] untill you had 'wo\000\000\000\000\000\000\000\000\000\000\000\000\000' you could then begin incrementing only [2..-1] untill you had 'wor\000\000\000\000\000\000\000\000\000\000\000\000' eg. the Range 'foo' ... 'bar' represents all the words greater than or equal to 'foo' but less than 'bar'. this seems to make some sort of sense doesn't it? perhaps i'm overlooking something here... so i guess i am reccomending that succ stay the same, but that iteration of string Ranges use my algorithim to generate all words > or == to start and < end (iff exclusive?). > Do you want to change how it works (to something doesn't work for > multibyte characters)? couldn't one simply substitute 256 -> sizeof(byte) and maintain my original algorithim? > |it also seems to make perfect sense for Float Ranges to have size Infinity? > |this would suprise no one. > > On the contrary, > > for x in 0.0 ... 42.0 > ... > end > > stops. confused ?? irb(main):001:0> for x in 0.0 ... 42.0; end TypeError: cannot iterate from Float from (irb):1:in `each' from (irb):1 -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================