Skip to content

Removesafe_ prefixes from math functions - #59

Merged
Hrom131 merged 2 commits into
devfrom
fix/consistent-naming
Oct 2, 2026
Merged

Hrom131 merged 2 commits into
devfrom
fix/consistent-naming

Conversation

@aritkulova

@aritkulova aritkulova commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator
  • This PR suggests a bug fix and I've added the necessary tests.
  • This PR introduces a new feature and I've discussed the update in an Issue or with the team.
  • This PR is just a minor change like a typo fix.

This PR is a follow-up to #57 and makes function naming consistent:

  • removes the _safe prefix so math functions are safe by default;
  • renames add -> add_carry;
  • renames sub -> sub_borrow;
  • renames mul -> mul_wide.

@aritkulova aritkulova self-assigned this Sep 28, 2026
@aritkulova
aritkulova requested a review from Hrom131 September 28, 2026 09:51
@Hrom131

Hrom131 commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

@aritkulova

What do you think about removing the safe_ prefix from all the remaining math operations (add, mul, sub)? It seems a little odd that they all still have the prefix, while div doesn't. I think we should keep the checked_ prefix and leave the functions without a prefix, which are safe by default.

@aritkulova

aritkulova commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

@Hrom131
Although add, sub, and mul still make sense as operations that can potentially overflow, I agree that removing the safe_ prefix would be more consistent.
I believe we should keep the current add, sub, and mul for u128 and u256 as unsafe_, since they are still useful. Should we return unsafe_div (for u128 and u256) for consistency then?

@aritkulova
aritkulova force-pushed the fix/consistent-naming branch from d4ac7b1 to 47790cb Compare October 2, 2026 08:13
`add` became `add_carry`;
`sub` - `sub_carry`;
`mul` - `mul_wide`.

@Hrom131 Hrom131 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Hrom131 Hrom131 changed the title Removesafe_ prefixes from div functions Removesafe_ prefixes from math functions Oct 2, 2026
@Hrom131
Hrom131 merged commit 91b486a into dev Oct 2, 2026
2 checks passed
@Hrom131
Hrom131 deleted the fix/consistent-naming branch October 2, 2026 11:01
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