> On 10 Apr 2014, at 07:53, Kevin Ballard <ke...@sb.org> wrote:
> 
> On Apr 9, 2014, at 9:50 PM, Tommi Tissari <rusty.ga...@icloud.com> wrote:
> 
>>> On 10 Apr 2014, at 00:22, Kevin Ballard <ke...@sb.org> wrote:
>>> 
>>> FWIW, my point about range is it relies on One being the number 1, rather 
>>> than being the multiplicative identity. AFAIK there's nothing special about 
>>> 1 in a ring outside of its status as a multiplicative identity. Certainly 
>>> it's not considered some special value for addition.
>> 
>> Another problem with std::iter::range is that it requires too much from its 
>> argument type A by saying A must implement Add<A, A> while it only returns a 
>> forward iterator.
>> 
>> Perhaps, in order to make a more sensible implementation of iter::range, a 
>> new concept, a trait, is needed to be able to specify that a certain type T 
>> implements a method 'increment' that modifies a variable of type T from 
>> value x to value y such that:
>> 1) x < y
>> 2) there is no valid value z of type T satisfying  x < z < y
>> 
>> For integral types there would an implementation of this trait in stdlib 
>> with 'increment' doing x += 1;
>> 
>> Then, a natural extension to this trait would be a trait that has a method 
>> 'advance(n: uint)' that would, at constant time, conceptually call the 
>> 'increment' method n times.
>> 
>> Then there would also be a 'decrement' method for going the other direction.
>> 
>> There probably needs to be some other use cases for this new trait to carry 
>> its weight though.
> 
> This trait would disallow range(0f32, 10f32) because there are quite a lot of 
> valid values z of type f32 satisfying 0f32 < z < 1f32.
> 
> -Kevin

The trait wouldn't disallow, but it would change the meaning of such range.

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to