Theres a subtle problem here that makes both solutions not work in
some cases.
I am trying to reexport error-kit, and it makes use of a var #'handle,
and in the macro with-handler, it tests if there is a handle  = to
#'handle. If you define a var in your own namespace named handle, it
will of course not be equal to #'clojure.contrib.error-kit/handle.
When you 'use' error-kit, it maps from the symbol handle to the
#'clojure.contrib.error-kit/handle , so everything works. However, all
exports from your namespaces have to have a (.ns var) = to the current
namespace - a clear contradiction. Therefore, it is not possible to
use the function 'use'. One would have to create a different function
to get this to work - maybe put a 'export' metadata and have the new
use function search for that.

On Jan 17, 10:12 pm, Ken Wesson <kwess...@gmail.com> wrote:
> On Mon, Jan 17, 2011 at 10:47 PM, Seth <wbu...@gmail.com> wrote:
> > if you 'use' ns A in ns B, ns C which uses B will not see the
> > functions of A. Im trying to create a ns which collects functions from
> > various other ns and exports them so that all you have to do is use
> > that one uber ns.
>
> And, Clojure being a language with good meta facilities, you figured
> it ought to be as easy as
>
> (ns uber-ns
>   :use (other-ns yet-another-ns))
>
> (foo other-ns)
> (foo yet-another-ns)
>
> for some choice of "foo".
>
> I'd figure something like this might work:
>
> (defn make-def [name value]
>   `(def name value))
>
> (defmacro foo [target-ns]
>   `(do
>      ~@(map
>          #(make-def % (symbol (str target-ns "/" %)))
>          (get-all-public-symbols target-ns))))
>
> given an implementation of "get-all-public-symbols" that, given a
> namespace *symbol* and *at macroexpansion time*, produces a seq of the
> symbols of public vars in that namespace; so if called on the symbol
> 'clojure.core it would produce something like ('condp 'for 'map 'doall
> 'println 'seq ...) and foo would produce something like (do (def condp
> clojure.core/condp) (def for clojure.core/for) ...).
>
> Making foo copy the metadata of the var as well as the value is left
> as an exercise for the reader. As is implementing
> get-all-public-symbols.

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