[Issue 10762] std.range.iota should support any type that has ordered comparisons, incrementing, and addition

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 5 13:41:40 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10762



--- Comment #4 from hsteoh at quickfur.ath.cx 2013-08-05 13:41:39 PDT ---
There are other considerations as well.

Let's say we are calling iota(start,end,inc).
Let S=typeof(start),
    E=typeof(end),
    I=typeof(inc),
    C=CommonType!(S,E).

Then:

1) Ideally, as long as C.init<end is a valid expression, and start+inc is
convertible to type C, then iota(start,end,inc) should be supported.

2) Should we optimize iota(start,end,inc) in the case that I supports integer
multiplication? That is to say, if n is an integer, and n*inc (or inc*n) is a
type that can be added to values of type C, then we could potentially return a
random access range wherein opIndex returns start + i*inc as long as the result
< end (we can throw a RangeError if result !< end). This might be a nice
optimization for things like BigInt in some cases.

3) If start+inc is *not* supported, but start++ is, then should we support
iota(start,end)?

4) If start+inc is *not* supported but start-- is, and end < start, should we
support iota(start,end)?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list