On Sun, Apr 24, 2011 at 5:17 AM, George Jahad
<[email protected]> wrote:
> so as Rich mentions in hacker news, you can get declare to work in
> other namespaces which does convert the circular dependencies issue
> from a compile time problem to a potential run-time one.
>
> The definition is pretty much what you would expect:
>
> (defmacro remote-declare [name]
> "declares the supplied ns-qualified name with no bindings, useful
> for creating circular dependencies"
> (let [[ns v] (.split (str name) "/")
> orig-ns (str *ns*)]
> `(do (in-ns '~(symbol ns))
> (clojure.core/declare ~(symbol v))
> (in-ns '~(symbol orig-ns)))))
Is there a reason for all the conversion to string and back? The below
seems simpler and equivalent:
(defmacro remote-declare [n]
"declares the supplied ns-qualified name with no bindings, useful
for creating circular dependencies"
(let [ns (namespace n)
v (name n)
orig-ns *ns*]
`(do (in-ns '~ns)
(clojure.core/declare ~v)
(in-ns '~orig-ns))))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en