Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arithmetic simplifications #115

Open
davidhesselbom opened this issue Sep 17, 2015 · 1 comment
Open

Arithmetic simplifications #115

davidhesselbom opened this issue Sep 17, 2015 · 1 comment
Milestone

Comments

@davidhesselbom
Copy link
Contributor

E.g. a = a + b can and should be written as a += b in many cases. Would it be possible for magic to detect this kind of thing?

@thomasfanell thomasfanell added this to the v0.3 milestone Sep 17, 2015
@davidhesselbom davidhesselbom changed the title Arithmetic simplications Arithmetic simplifications Sep 17, 2015
@davidpiuva
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants