[Issue 6652] foreach parameter with number range is always ref
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 12 15:10:28 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6652
--- Comment #3 from bearophile_hugs at eml.cc 2011-09-12 15:10:08 PDT ---
(In reply to comment #2)
> Making a const/immutable copy is not the right solution to this.
Keep in mind that foreach(i;0..10) must have *zero* abstraction penalty over a
for loop even with non-optimizing D compilers, because it's meant to replace
for loops everywhere possible. The more abstraction you put into foreach there
higher the probability it will not have zero abstraction penalty (currently it
has a bit of penalty for nested loops, sometimes).
> not possible using const:
> foreach(i; 1 .. 10)
> while(i--) { do some }
Use a for loop :-)
--
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