|I wish there was a way to pass variables to functions "implicitly". As if by setting "global" variables, but without polluting the global scope.|
After w/config exits, x is set back to 5.
(= x 5)
(def some-fn (name)
(prn "Hello " name ", x = " x))
arc> (w/config (x 10)
Hello There, x = 10
I could easily write a macro for that (in fact, I did write one). The problem is when we have multiple threads. I want w/config to only affect the current call stack. Call stacks running in other threads are by definition not part of the current call stack.
Hello Here, x = 5
I think this kind of thing is called Dynamic Scoping