code-reviews

dottedmag 2019-07-22T08:06:54.001300Z

Please suggest how to improve this code (and whether it needs to be improved): https://gist.github.com/dottedmag/f38b25718cb151b81ed429312092546b (reformatted slightly, now at rev. 6)

dmaiocchi 2019-07-22T11:52:06.002200Z

https://gist.github.com/dottedmag/f38b25718cb151b81ed429312092546b#file-resource-id-clj-L27 I would personally don't mix state management within in a let scope

dmaiocchi 2019-07-22T11:53:17.003400Z

from my pov, doing a swap in a let, it mix side-effects withing the let, which in theory should be just an utility convenenice for having a scope variable`let` imho. Open to see what other think about that

dmaiocchi 2019-07-22T11:54:57.004Z

a part of this, Imho instead of if you could use the or construct but this is more style

2019-07-22T17:22:10.004500Z

use compare-and-set! instead of swap

2019-07-22T17:22:54.005Z

using swap! for that kind of thing is asking for a race condition

2019-07-22T17:23:37.005400Z

I might use a semaphore instead of any of that

2019-07-22T17:24:07.005800Z

but I guess a semaphore wouldn't tell you which id is free

2019-07-22T17:24:27.006100Z

you could just use a linkedblockingqueue of ids