clojure-dev

Issues: https://clojure.atlassian.net/browse/CLJ | Guide: https://insideclojure.org/2015/05/01/contributing-clojure/
vlaaad 2020-05-10T05:41:41.150400Z

You can achieve same performance with multiple arities of vswap! function

vlaaad 2020-05-10T05:42:39.150500Z

(vswap! (volatile! (prn 1)) identity)

vlaaad 2020-05-10T05:42:57.150600Z

Prints "1" twice

serioga 2020-05-10T09:55:54.154100Z

@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

vlaaad 2020-05-10T09:57:09.154500Z

You can doo all that without making vswap! a macro

serioga 2020-05-10T10:00:04.155800Z

> Prints "1" twice looks like it is not designed to work with volatiles which you cannot access directly 🙂

serioga 2020-05-10T10:14:17.156500Z

well, only @alexmiller can answer if he remembers 🙂 https://clojurians.slack.com/archives/C06E3HYPR/p1589057208146700

vlaaad 2020-05-10T10:22:08.157100Z

found a relevant issue: https://clojure.atlassian.net/projects/CLJ/issues/CLJ-1777

2
vlaaad 2020-05-10T10:25:22.158Z

the discussion in the comments seems to be derailed because of :inline in the patch...

ghadi 2020-05-10T12:54:31.161100Z

@vlaaad what is the problem you are experiencing?

2020-05-10T15:51:10.164Z

Just use an atom, you get a function for swap and as a bonus it is race free under contention, volatile is not

vlaaad 2020-05-10T16:03:22.164200Z

I know when to choose atoms and when to choose volatiles :)