Rich,

I know I could search through clojure source code for this question (and
that this question is not totally related to the current thread), but could
you please tell me if there is a possibility to watch for additions/removals
of vars to a namespace, and additions/removals of namespaces to the "global
set of namespaces".

What I would like to do is being able to maintain, dynamically, a dependency
graph of the files in a project and what they are really doing (thus
correctly handling cases difficult or not possible at all to do via static
analysis such as macros defining vars, multiple ns created per file, ns
decomposed in multiple files ...). And I guess having the above mentioned
facility would help for this.

Are namespaces & global set of namespaces "watchable" things ?

Thanks in advance,

-- 
Laurent

2009/2/27 Rich Hickey <richhic...@gmail.com>

>
> I've added (back) synchronous watches (svn 1309+), which used to exist
> for agents, now for all reference types.
>
> (defn add-watch
>
>  "Experimental.
>
>  Adds a watch function to an agent/atom/var/ref reference. The watch
>  fn must be a fn of 4 args: a key, the reference, its old-state, its
>  new-state. Whenever the reference's state might have been changed,
>  any registered watches will have their functions called. The watch
> fn
>  will be called synchronously, on the agent's thread if an agent,
>  before any pending sends if agent or ref. Note that an atom's or
>  ref's state may have changed again prior to the fn call, so use
>  old-state rather than derefing the reference. Note also that watch
> fns
>  may be called from multiple threads simultaneously. Var watchers are
>  triggered only by root binding changes, not thread-local set!s"
>
>  [reference key fn] ...)
>
> (defn remove-watch [reference key]...)
>
> I've left in add/remove-watcher for now, in order to avoid disruption.
> It is defined in terms of add-watch, demonstrating add-watch is the
> more flexible core function. My plan is to remove add-watcher/remove-
> watcher, since you can build your own such variants.
>
> Highlights are:
>
> - Deterministic times when callbacks will occur.
>
> - Provision of before/after state - you determine what constitutes an
> interesting change.
>
> - Arbitrary key will be passed back to callback.
>
> Please try them out for your latest Cells-like and other reactive
> programs. I'd like to move this out of the experimental category.
>
> Feedback and questions welcome,
>
> Rich
>
> >
>

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