You can achieve same performance with multiple arities of vswap! function
(vswap! (volatile! (prn 1)) identity)
Prints "1" twice
@vlaaad As I see vswap!
is implemented as macro just to assign the type hint to volatile and avoid reflection on .reset
and .deref
invocations
You can doo all that without making vswap!
a macro
> Prints "1" twice looks like it is not designed to work with volatiles which you cannot access directly 🙂
well, only @alexmiller can answer if he remembers 🙂 https://clojurians.slack.com/archives/C06E3HYPR/p1589057208146700
found a relevant issue: https://clojure.atlassian.net/projects/CLJ/issues/CLJ-1777
the discussion in the comments seems to be derailed because of :inline
in the patch...
@vlaaad what is the problem you are experiencing?
Just use an atom, you get a function for swap and as a bonus it is race free under contention, volatile is not
I know when to choose atoms and when to choose volatiles :)