Bug 15139 – allow foreach over Range*

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-10-02T19:39:09Z
Last change time
2024-12-13T18:45:02Z
Assigned to
No Owner
Creator
John Colvin
Moved to GitHub: dmd#19052 →

Comments

Comment #0 by john.loughran.colvin — 2015-10-02T19:39:09Z
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*)); //but static assert(!isIterable!(typeof(a)*)); //because 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 https://issues.dlang.org/show_bug.cgi?id=15096 Note that pointers to ranges can't pass hasSlicing or IsRandomAccessRange because of course the indexing would be all wrong.
Comment #1 by robert.schadek — 2024-12-13T18:45:02Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19052 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB