On Sep 9, 8:17 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> Rich mentioned a desire for the "ns-*" functions to accept either a
> symbol or a namespace for arguments where they currently accept a
> namespace.
>
> Using a multimethod that dispatches on the class of that argument is
> one way to do that.
>
> Here's an example:
>
>         (defmulti ns-aliases class)
>
>         (defmethod ns-aliases clojure.lang.Symbol
>           [ns]
>           (ns-aliases (find-ns ns)))
>
>         (defmethod ns-aliases clojure.lang.Namespace
>           [#^clojure.lang.Namespace ns]
>           (.getAliases ns))
>
> Is this a good way to accomplish the goal or is it a poor choice for
> some reason?
>

It would work, but it seems like overkill. In particular, there's no
intention to extend it any further, and all symbol versions do the
same thing, call find-ns and delegate, so maybe just adding a let
level to the existing fns is best:

(let [ns (the-ns ns)] ...)

where the-ns x is just (if (instance? Namespace x) x (find-ns x))

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to