Thanks for the replies!
Before I start doing something silly, I would like to ask another
question. The eventual goal of all of this is to establish bindings
which also affect the same global variable in other namespaces (these
other namespaces will 100% have the same global variable). In other
words, an equivalent of binding which affects all namespaces.  Also i
want a binding which will
affect threads that I start (this is easy, i can just pass the one var
as a parameter?).

Anyone have any suggestions on how they would do this. The solution
has to be fast as this binding will be occuring fairly often and
rapid.

At first I considered a global variable to which i would push a value
then pop it once the binding was done. However, I eventually rejected
this because there is no way to control access to this one global var
without freezing the whole program (refs won't do..). With threads,
without this ref, everything would get messed up if a thread suddenly
got killed without popping. This would spell disaster for the whole
program so...

Then I considered having a unique global variable per thread. Then
somehhow i would get the thread id and hash that with the current
value. Anything which needed to use the same variable would looks up
its thread id and then look in the global hash to see the value. Then
i rejected that because I'm guessing first its probably inefficient to
do this and I don't know even how that would work.

Finally i considered using the binding form and in order to achieve
the binding across namespaces redefine the defn to create two
functions, one which take as the first argument a special structure
which includes the new binding. Then the function would bind it in its
own namespace. This function would be a gensymed name, so i could call
the function regularly in my code and amacro would take care of
expanding it. However, on the other hand, i would most definitely want
these to be used as functions so i was considering redefining apply to
allow this functionality

Does map and all those functions use apply, though? I doubt it. So
maybe that idea is cracked.

Notice that this binding is going to be happening very often, so the
solution has to be fast enough. Anyone have any ideas? And yes, i have
to bind global variables across namespaces.

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