Clojure's binding form only establishes vars with dynamic extent
limited to the current thread. This makes a lot of sense. However, I
have a use case where I'd like it to establish the dynamic extent in a
way which affects the current thread and all threads started within
the current thread.

Suppose, for example, that I want to launch a couple of different
instances of the embedded Jetty server. I have no control over what
threads Jetty starts and stops, but I want to make sure that my code
running inside that entire instance has a specific "global" variable
binding:

(declare *x*)

(binding* [*x* 3]
  (start-jetty :port 8001 :my-servlet servlet-implemented-in-clojure))

(binding* [*x* 5]
  (start-jetty :port 8002 :my-servlet servlet-implemented-in-clojure))

That way, code I wrote to run inside of Jetty can blindly refer to
*x*, and the first instance would then use the value 3, and the second
instance would use the value 5. Basically, I'd like a binding* macro
to establish a dynamic binding visible only in thread hierarchies
started in its scope.

Aside from the utility in my use case, I think a binding* macro like
this would improve the current concurrency situation, where any thread
can alter a def'ed global variable for any other thread. If the thread
starts in a binding*, it would, at worst, affect itself and its
children. Seems useful.

Any comments? Is this possible? How difficult would this be to
implement?

Best regards,
Constantine Vetoshev

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to