Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
July 27, 2014 [Issue 4508] tuples should be indexable with foreach over range | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=4508 Vlad Levenfeld <vlevenfeld@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vlevenfeld@gmail.com -- |
October 11, 2014 [Issue 4508] tuples should be indexable with foreach over range | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=4508 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #1 from bearophile_hugs@eml.cc --- I think this is a bad idea, in this form. So I suggest to close this issue. I prefer this syntax much more: static foreach(i; 0..tup.length) { -- |
April 20, 2017 [Issue 4508] tuples should be indexable with foreach over range | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=4508 Nick Treleaven <nick@geany.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@geany.org --- Comment #2 from Nick Treleaven <nick@geany.org> --- `foreach (e; seq)` works at compile time for an AliasSeq, so I don't see why `foreach (i; low..high)` can't make `i` known at compile-time if the bounds are known. I think we should rename this bug to apply to any CT-knowable index in a ForeachRangeStatement. -- |
April 20, 2017 [Issue 4508] tuples should be indexable with foreach over range | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=4508 ag0aep6g@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ag0aep6g@gmail.com --- Comment #3 from ag0aep6g@gmail.com --- (In reply to Nick Treleaven from comment #2) > `foreach (e; seq)` works at compile time for an AliasSeq, so I don't see why > `foreach (i; low..high)` can't make `i` known at compile-time if the bounds > are known. Can `i` be made known at compile-time without unrolling the loop (in the binary)? Surely we don't want to unroll every loop that can possibly be unrolled. For example, it would be very surprising if the compiler unrolled a loop like `foreach (i; 0 .. uint.max) writeln(i);`, generating gigabytes of machine code. -- |
April 22, 2017 [Issue 4508] tuples should be indexable with foreach over range | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=4508 --- Comment #4 from Nick Treleaven <nick@geany.org> --- In that case, perhaps we could use `static foreach` as in comment 1. -- |
May 17, 2018 [Issue 4508] tuples should be indexable with foreach over range | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=4508 Dmitry Olshansky <dmitry.olsh@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |dmitry.olsh@gmail.com Resolution|--- |FIXED --- Comment #5 from Dmitry Olshansky <dmitry.olsh@gmail.com> --- With static foreach you can do this, and AFAICT is exactly what is required: import std.typecons; void main() { auto tup = tuple(1, "foo", 3.0).expand; static foreach(i; 0..tup.length) {{ auto val = tup[i]; }} } -- |
Copyright © 1999-2021 by the D Language Foundation