Hi Nicolas,
I've done a bit of manipulation of namespaces for dynamic loading and
executing of functions in a web app context which might give you some
ideas...
Here ns-nm and ipath have been extracted from a url. Then...
(let [ .....
ipath (if (or (nil? ipath) (= ipath "")) "root" ipath)
ipath (if (.startsWith ipath "/") (.substring ipath 1) ipath)
ns-sym (symbol ns-nm)
found-ns (find-ns ns-sym)
found-ns (if (nil? found-ns)
(let [n (create-ns ns-sym)]
(require ns-sym) n)
found-ns)
_ (when (nil? found-ns)
(throw (IllegalArgumentException.
(str "Namespace not found for: " ns-sym))))
req-fn (get (ns-publics ns-sym) (symbol ipath)) ]
(req-fn .......
So, the requisite functions you can use are;
create-ns
require
ns-publics
and you can role your own :).
-Hope that helps a bit, Adrian.
On Wed, Aug 18, 2010 at 12:24 PM, Nicolas Oury <[email protected]> wrote:
> That helps a lot. Thank you very much.
>
> That is not very nice though. I quite would like a :reexport option to use.
>
> Best,
>
> Nicolas.
>
>
> On Wed, Aug 18, 2010 at 11:17 AM, Meikel Brandmeyer <[email protected]> wrote:
>> There is no standard way of doing that. There is immigrate of an old
>> Compojure version, which is a hack at best. If all functions should
>> end up in one namespace anyway, you can have a master file, which
>> basically loads the other files.
>>
>> my/name/space.clj:
>>
>> (ns my.name.space
>> (:load "a" "b" "c"))
>>
>> my/name/{a,b,c}.clj:
>>
>> (in-ns 'my.name.space)
>>
>> ....
>>
>> Hope that helps.
>>
>> Sincerely
>> Meikel
>>
>
> --
> 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
--
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