bearophile escribió:
Once that optimization is in place, the reading access to associative arrays too can be marked as "pure" so the in the following code h["bar"] is seen as a loop invariant, and computed only once before the loop:import std.c.stdio: printf; int foo(int[string] h) { int x; for (int i; i < 100; i++) x += h["bar"]; return x; } void main() { printf("%d\n", foo(["bar": 42])); }
What if a different thread modifies h in between the loop?
