[Issue 5351] Add template mixin for Range Primitives using random access

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 4 09:55:27 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=5351

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #5 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
isRandomAccessRange is a compile-time construct, and checking foo[0] ==
foo.front is generally not possible at compile-time. Even if it is, the fact
they're equal right now doesn't mean they always will be (consider the
fibonacci sequence 1,1,2,3,5,8,13,21..., which would have foo[0] == foo.front
after one popFront, but not two).

In addition, as you say, having an indexable range with semantics different
from random access ranges is not at all desirable, and a recipe for disaster at
some later point.

I agree having this kind of functionality in Phobos would be nice, but I don't
see a workable path to that goal. I'm closing this - please reopen if there are
revelations that make it possible in the future.

--


More information about the Digitalmars-d-bugs mailing list