2013/3/13 Mark Engelberg <mark.engelb...@gmail.com>

> Still, it would be nice to understand whether it's possible to achieve the
> same effect as Clojure core's settable vars.
>

It is, because clojure doesn't do anything magic here (apart from the
effects its set!-able vars have ;-).
The catch is: The set of commonly set!-able vars is tied to clojure's
release version. And as we all know, this context is controlled by
clojure/core, in the hope of ruling out bad majority decisions.

Proof by command line:

> java -cp clojure-1.5.0.jar clojure.main -h
... snip ...
  operation:

    - Establishes thread-local bindings for commonly set!-able vars
... snip ...

So presumably, you would have to get the var you want to have "globally"
set!-able into clojure.main, or lobby for a general purpose hook to
globally add dynamic bindings to a thread (a bad idea in my gut intuition).

*user=>* (.start (Thread. #(set! *unchecked-math* true)))
nil
Exception in thread "Thread-3" java.lang.IllegalStateException: Can't
change/establish root binding of: *unchecked-math* with set
 at clojure.lang.Var.set(Var.java:233)

;; so no, clojures set!-able vars aren't magically carried over to new
threads either

Opinions

IMO set!-able vars only make sense, if you control the context in which the
vars are set!-able. Dynamic bindings are plenty volatile as they are,
especially in combination with lazy sequences (just happened to me again
today). The ability to introduce *new* bindings *across* or *up* the
dynamic scope certainly wouldn't help there.

I think the easiest way to offer your users to control part of their
context (to "globally" introduce set!-able vars and other stuff) are:
leiningen plugins.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to