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

Make arithmetic operations n-ary when it makes sense #343

Open
gsimone opened this issue Oct 27, 2022 · 4 comments
Open

Make arithmetic operations n-ary when it makes sense #343

gsimone opened this issue Oct 27, 2022 · 4 comments

Comments

@gsimone
Copy link

gsimone commented Oct 27, 2022

eg:

// now
Mul(a, Mul(b, Mul(c, Mul(1, 3 )))
// then 
Mul(a, b, c, 1, 3 ) // becomes => a * b * c * 1. * 3.
Add(a, b, c, 1, 3 ) // becomes => a + b + c + 1. + 3.
@hmans
Copy link
Owner

hmans commented Oct 27, 2022

What is the expected behavior for subtraction and division? Consider that

Sub(a, Sub(b, Sub(c, d)))

is equivalent to

a - (b - (c - d))

while this

Sub(a, b, c, d)

sort of implies

a - b - c - d

Thoughts?

@gsimone
Copy link
Author

gsimone commented Oct 27, 2022

Probably should only be for commutative operations?

@hmans
Copy link
Owner

hmans commented Oct 27, 2022

I think it'd be fine to have Sub(a, b, c, d) compile to a - b - c - d and leave it to documentation to explain how it's different from Sub(a, Sub(b, Sub(c, d))). (Same with division.) Would you see any issues with this?

@gsimone
Copy link
Author

gsimone commented Oct 27, 2022

Expectations might be a problem, rather not have it for non-commutative operations than have a behaviour that's not immediately obvious - as it is for commutative

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

2 participants