Request: Int.post_incr
Closed this issue · 2 comments
johnyob commented
As with incr
(which pre-increments an int ref
), it would be extremely useful to have a post-increment function post_incr
:
let post_incr r =
let result = !r in
incr r;
result
bcc32 commented
FWIW, incr
doesn't pre-increment an int ref
, it just does the increment step. Either way, you have to read the value in a separate step from incrementing it.
Can you give an example where this would be useful? I have a hard time thinking up where this might be needed in idiomatic OCaml code.
bcc32 commented
I think we're pretty unlikely to add this, so I'm closing this issue. If there is a compelling use case we might not be considering, you can reopen the issue.