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

Deprecate minusAssign/plusAssign operators from public API #416

Closed
mvicsokolova opened this issue Apr 4, 2024 · 3 comments
Closed

Deprecate minusAssign/plusAssign operators from public API #416

mvicsokolova opened this issue Apr 4, 2024 · 3 comments

Comments

@mvicsokolova
Copy link
Collaborator

mvicsokolova commented Apr 4, 2024

I suggest to remove minusAssign/plusAssign operators from public API of AtomicInt and AtomicLong.

  • these operators are not consistent with the API of Java atomics, K/N atomics and it's better to use addAndGet instead.
  • this API is not widely used (though I should check that properly)
  • these operators were added just because they seemed useful

Not the reasons to remove the API, but related problems:

Alternative solution is to solve the problems above and keep the API.
And of course it's more convenient to write:

private val x = atomic(0)

x -= 5

vs

private val x = atomic(0)

x.addAndGet(-5)

@fzhinkin WDYT? 👀

@lppedd
Copy link

lppedd commented Apr 4, 2024

IMO the operator functions feel more natural. And I can swap an atomic with a normal number type (and vice-versa) without changes.

People working with Kotlin should be aware of operator functions, and the IDE provides navigation to the target in case one wants to explore the code.

@mvicsokolova
Copy link
Collaborator Author

That's a good point, right.

@mvicsokolova mvicsokolova moved this to Questionable in Atomicfu Apr 27, 2024
@mvicsokolova
Copy link
Collaborator Author

These operators will be supported in the atomicfu compiler plugin for the future Kotlin versions: KT-67839

@github-project-automation github-project-automation bot moved this from Questionable to Done in Atomicfu Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants