-
Notifications
You must be signed in to change notification settings - Fork 14
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
fixes #40: account for mutation of map in getOrInsertComputed callbacks #71
base: main
Are you sure you want to change the base?
Conversation
I would strongly prefer that this throw rather than returning the value which was inserted while the callback was running. If that's not acceptable, it should return the value produced by the callback. In no circumstances should it call the callback and then silently not insert that value. |
@bakkot Read it again, it sets the value and returns that value, regardless of what it was set to in the interim. |
Ah, good good. Well, I'd still prefer an error. Incidentally, Java says:
|
I'm also fine with locking and throwing. This design question should probably be posed to committee @dminor. |
Locking requires a lot more implementation work. Maybe it's easy in practice and doesn't slow down other uses, Actually, on further thought, I am against locking even if it is easy to do because right now |
I'll just open a second PR right now to make it easier for people to compare. edit: See #73. |
I've requested a larger timebox, and I'll add this issue to the slides for discussion in committee. |
Fixes #40. Just checks for presence of the key again after calling the callback. @dead-claudia suggested we could have a note about a potential optimisation here, but I'll leave that to the editor group to decide upon integration.
Closes #73.