On Tuesday, 12 March 2013 at 15:02:44 UTC, monarch_dodra wrote:
Right, that's what I said. This first paragraph was just about
enum empty = false.
The actual "isInfinite" discussion comes later.
Another point: isInfinite is useful, if only to propagate
infiniteness. For example: "1.repeat().map"a * 2"()". If "map"
didn't know that repeat is infinite, it would simply provide
the "dumb" empty implementation, and the final range will have
lost it's infinite trait.
That will always be optimized away without trouble by existing
compilers. You'd loose the character of infinitness, but it seems
to me like a lot of trouble as it add a whole class of things to
consider when implementing wrapper ranges, for benefice that you
can already get most of the time.
Note that something like computeIfCTFEable!(r.empty, true) would
be much more beneficial than the actual implementation.