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

[Feature]: seperate mutative from immutable api for Int #18066

Open
tac0turtle opened this issue Oct 11, 2023 · 3 comments
Open

[Feature]: seperate mutative from immutable api for Int #18066

tac0turtle opened this issue Oct 11, 2023 · 3 comments
Labels

Comments

@tac0turtle
Copy link
Member

tac0turtle commented Oct 11, 2023

Summary

There has been a need for more mutable apis in math, they have been getting added to the current struct which could cause confusion for users.

Problem Definition

separate immutable from mutable in math

Proposed Feature

Create a new mutable struct for users to use when needed.

New api to add:

@julienrbrt
Copy link
Member

Additionally, we can revert this (#17803, that hasn't been released and which would fit here.
I'll edit your message above.

@testinginprod
Copy link
Contributor

testinginprod commented Oct 12, 2023

The proposal would be to introduce a new type: type IntMut Int  which can be converted from and to Int with little to no overhead by doing (IntMut)(Int) and vice-versa (Int)(IntMut), then the mutative API would be implemented on top of IntMut, this would reduce the API surface of Int which is already big and support the mutative API in a performant way.

Eg:

type IntMut Int

func (i IntMut) ToInt() Int { return (Int)(i) }

func (i IntMut) Quo/Add/Sub/Etc() { ... } 

func (i Int) ToIntMutUnsafe() IntMut { return (IntMut)(i) }
func (i Int) ToIntMut() IntMut { return NewIntMutFromBigInt(i) } // this NewIntMutFromBigInt would copy the underlying Int.bigInt

@julienrbrt
Copy link
Member

FWIW comment from the bot: #18247 (comment)

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

Successfully merging a pull request may close this issue.

3 participants