On Monday 04 October 2004 09:09 pm, Charles Comstock wrote:
> Yes but [start,length] is capable of expressing ranges that make no
> sense using [range].  For instance:
>
> a = [:a,:b,:c,:d,:e,:f,:g,:h]
> a[-2,2] # => [:g,:h]
> a[-2..2] # => []
> a[-2..-1] # => [:g, :h]
> a[0..-1] # => [:a,:b,:c,:d,:e,:f,:g,:h]
>
> Obviously it isn't too hard to convert between the two formats, but many
> times it makes far more sense to express it in the [start,length] format
> as opposed to the range format of start..end.

Hmm... It's still signifies a range. So if there were just a notation, then it 
might be nice. I'm not sure what that would be though.

Really, in looking over Ruby's Range class, it is bit limited. You can't 
exclude the start element, and it doesn't provide a way to specify a 
increment so you can't iterate over floats. A more complete range would have 
the initializer something like:

  Range.new(start, end, start_exclude=false, end_exclude=false, inc=1)

Again, sure the best way to make a nice neat literal notation for all that. 
Although one simple suggestion is to have a '+' method to set the increment.

  (1.0 .. 3.0 + 0.5).to_a  #=> [1.0, 1.5, 2.0, 2.5, 3.0]

T.