Open davidhesselbom opened 9 years ago
The algebraic rules can be quite complex and would require functional purity on all functions bound to the operands.
a = (a + b) + c
<=> a = a + (b + c)
<=> a += b + c
.
a = a * b + c
is not equivalent to a =* b + c
because of precedence.
If A is a collection then we cannot use += because the language looks up by value.
array[x] = array[x] + 1
will read by value, add and write by value.
There are also cases of aliasing that can confuse a compiler.
a = b + c
=> a += c
if &a = &b
.
E.g.
a = a + b
can and should be written asa += b
in many cases. Would it be possible for magic to detect this kind of thing?