On Tuesday, 18 August 2015 at 16:02:42 UTC, cym13 wrote:
On Tuesday, 18 August 2015 at 15:51:55 UTC, ixid wrote:
Though sugar seems to be somewhat looked down upon I thought
I'd suggest this- having seen the cartesianProduct function
from std.algorithm in another thread I thought it would be an
excellent piece of sugar in the language. It's not an earth
shattering change but it makes something very common more
elegant and reduces indentation significantly for multiple
nested loops. Braces make nested loops very messy and any
significant quantity of code in the loop body benefits from
not being in a messy nesting.
...
What would you do with associative arrays?
void main() {
auto aa = [1:1, 2:2];
foreach (a, b ; aa, 1..10)
foo(a, b);
}
Prevent both iterator count and associative value variables for
foreach loops with nested loops. This behaviour of associative
arrays is already an odd case as it clashes with the iterator
behaviour for other arrays.