www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15139] New: allow foreach over Range*


          Issue ID: 15139
           Summary: allow foreach over Range*
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: john.loughran.colvin gmail.com

We should allow foreach over pointers to range types, or alternatively change
std.range.isInputRange to disallow pointers to range types.

Currently we have this:

alias Range = Repeat!int;

static assert(isInputRange!(Range*));
static assert(!isIterable!(typeof(a)*));
static assert(!__traits(compiles, { foreach(_; &a){} }));

so just because you checked whether something is an input range, doesn't mean
you can actually use foreach over it.

One way or another, resolving this would deal with
https://issues.dlang.org/show_bug.cgi?id=11779 and

Note that pointers to ranges can't pass hasSlicing or IsRandomAccessRange
because of course the indexing would be all wrong.

Oct 02 2015