Clojurians
#cljs-dev
<
2016-10-06
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

tomjkidd00:10:42

I'm new to looking at the source code, and I see dynamic vars being used for binding context for the environment(s). Just curious is there a reason that dynamic vars were used, necessitating binding, instead of something like atoms to represent the values that could be passed into the functions?

dnolen03:10:15

@tomjkidd we use atoms, kind of unrelated to how/why we use dynamic bindings.

dnolen03:10:43

if you have a more specific inquiry, then ask that.

thheller10:10:53

@dnolen do you use Cursive when working on clojurescript?

thheller10:10:49

or anyone else here running Cursive for the cljs project?

viebel15:10:15

@dnolen (cont. the discussion from #clojure-spec): would you like a patch to clojurescript that brings specs.clj from clojure?

dnolen15:10:57

No yet, just file a ticket if it doesn't exist

tomjkidd19:10:30

@dnolen It was kind of a half-cocked question. I am looking at the code along the path where i use lein cljsbuild auto. I think I am just a little mixed up due to reading through the code quickly. I am going to spend more time to make sense of it, but I am curious. Since you mentioned there is a how/why for use of dynamic bindings, could you elaborate on that a little?

tomjkidd19:10:49

It comes from my experience so far that I have just used atoms to manage state, and I am still trying to get a feel for when it is appropriate to use dynamic bindings

tomjkidd19:10:54

I do have some materials (a number of books and I've found posts by Stuart Sierra about it). If it is arbitrary, fine.

dnolen19:10:59

@tomjkidd there a couple of nice things, bindings are thread local - we often bind value at the start of processing a file on thread (i.e. :parallel-build true)

dnolen19:10:16

I don’t have time to elaborate further - I recommend just reading the source

tomjkidd19:10:38

@dnolen will do, thank you

darwin21:10:50

@tomjkidd I tend to think about bindings as “temporary hidden parameters”, it is a way how to pass parameters to functions which will be called down from you stack frame (by current thread in case of clojure)

darwin21:10:28

this way you don’t need to change signatures of intermediate functions, which could be impractical

darwin21:10:16

e.g. imagine a world where you had to pass *out* to every function because they might want to call println

darwin21:10:14

of course you could achieve similar results with atoms or other global refs, but bindings are lightweight, explicitly thread-bound and “temporary”, they should not hold persistent app-state in a sense as atoms do, they should contain only temporary parametrizations valid for a function call at hand

tomjkidd21:10:27

@darwin Thanks, I am actually making a little diagram for myself of closure/build and that explanation is helpful.

tomjkidd21:10:29

There aren't as many earmuffs as I originally thought.