yvan.godin
2018-4-21 10:41:26

@yvan.godin has joined the channel


greg
2018-4-21 14:54:39

Ha yes boxes confused me, too. My current understanding: I rarely use boxes. Often parameters — not function args, I mean make-parameter parameters — are a nice way to hold mutable state. Now, parameter values are per-thread. Often that is nice and exactly what you want. When all threads should share one value, sometimes a nice way to express that is to use a box and update it atomically with box-cas! https://docs.racket-lang.org/reference/boxes.html#%28def._%28%28quote._~23~25kernel%29._box-cas%21%29%29


greg
2018-4-21 14:55:50

You can also build on top of that to do things like Clojure’s swap! for refs, e.g. a box-swap! https://docs.racket-lang.org/rackjure/index.html#%28def._%28%28lib._rackjure%2Futils..rkt%29._box-swap%21%29%29


greg
2018-4-21 14:57:16

@cosmez ^


greg
2018-4-21 14:57:36

So that’s my current understanding, which is maybe still not quite complete or correct, but… ¯_(ツ)_/¯


cosmez
2018-4-21 18:56:08

parameter value per-thread. that means if i create a parameter outside the trade scope, it will create a copy for that thread ?


greg
2018-4-22 03:03:42

Yes parameters are built on top of thread cells. A new thread initially inherits a copy of the value. Thereafter the value is independent.