I have some private functions in one namespace that I would like to include in a second namespace. e.g.
(ns one)
(defn ^:private foo
"A docstring"
[x] (* x 2))
And the second namespace needs to create an alias to this:
(ns two)
(def foo ???)
(foo 3) ;; should work as if the function in namespace one was called
=> 6
Ideally I'd like to preserve the docstring so I don't have to maintain it in two places. Also I'd like to have the option to either use the same name or a different name.
The reason for this requirement is as follows: the functionality is needed/used in namespace one. one is a dependency of two, and since we can't have circular dependencies it won't work to define foo within two itself. two is the public API, so foo needs to be publicly part of the two namespace.
What's the best way to achieve this?
(def foo (with-meta one/foo (meta #'one/foo)))- Ankurfooinone? And why is it private? Obviously it should be intwoand public... - kotaraktwois the public API. - mikera