From: Ara.T.Howard@... Date: 2004-10-08T02:04:48+09:00 Subject: Re: Range behavior (Re: [RCR] New [] Semantics) On Fri, 8 Oct 2004, trans. (T. Onoma) wrote: > A BIG question that comes to mind after reading your post is this: What do > people usually use Range for? - huge indexes sets into binary data - open ended time ranges (infinity one one end) - floating point intervals - sets of strings > Is it continuous or discrete? both > I know there is some of both, but I wonder if one far exceeds the other. > Hopefully yes, b/c I think the solution must basically fall to something > like this: > - Range is defined as discrete. It represents an iterative set. this seems limiting because it disallows even the most basic ranges like float ranges - which are both infinite and continuous. also, if you allow user defined succ procs you allow non-discrete discrete objects. in otherwords you give the user the ability to break the definition which is like allowing a method of Array to somehow make and Array not an Array - this can't be good. i realize we are talking about the coder making an infinite loop for himself, but what's different here is that you are wanting to encapsulate loop behaviour. if you encapsulate a discrete loop then all operations on that loop should not be able to break it's discretness no? > - Range is Enumerable, and #include? is the same as #member? and #===. this eliminates some of the most useful aspects of ranges though? eg: now = Time::now period = (now ... (now + 42.days)) then = method_returning_time_with_usecs do_something if period.include? then > - A new class is made for the continuous uses called Interval. that would break alot of code. why not flip flop: leave Range the way it is and introduce a new class called IterativeSet or Iteration or DiscreteRange or something. this might be more inline with what you are wanting. for example it might make sense for Iterations to be able to do this: it = Iteration::new 0, 42 it.iterate(1){|i| p i} #=> 0, 1, 2, 3, etc... it.iterate(2){|i| p i} #=> 0, 2, 4, 6, etc... perhaps there could even be a literal it = 0 -> 42 it.each{|i| p i} or it = 0 +> 42 it.each{|i| p i} where the -> or +> indicate a 'step' operator kind regards. -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen ===============================================================================