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

Implement arithmetic operators with a macro #4

Closed
wants to merge 2 commits into from

Conversation

Antonio95
Copy link

We realised the previous implementation of operators *, /, - for owned types (instead of references) broke some things. For instance, this line in poly-commit stopped compiling.

In the specific example given, the reason for the new failure is that, when operators were only implemented for &poly / &poly, the compiler implicitly converted the call f_poly.div(&z_poly); into (&f_poly).div(&z_poly);. But after we had added poly / poly, the compiler was not clever enough to add the reference and complained that poly / RHS should have RHS of type poly (not &poly).

Long story short, the best way to ensure the new operator definitions are not a breaking change is to implement poly / poly, poly / &poly and &poly / poly (all of them falling back to the honestly defined &poly / &poly). Since that had to be done for several operators, a macro seemed like the best approach.

Cesar199999 and others added 2 commits June 26, 2024 11:07
Co-authored-by: Antonio Mejías Gil <anmegi.95@gmail.com>
Co-authored-by: Antonio Mejías Gil <anmegi.95@gmail.com>
@Antonio95 Antonio95 closed this Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants