ns-unmap-all

98 views
Skip to first unread message

blais

unread,
Sep 11, 2010, 9:48:35 PM9/11/10
to Clojure
Hi,
The following function has been a real _lifesaver_ lately in debugging
symbol collisions in (ns) directives when developing with SLIME in a
long-running VM:

(defn ns-unmap-all
"Unmap all the symbols (except 'ns' and 'in-ns')."
([] (ns-unmap-all *ns*))
([ns] (map #(ns-unmap ns %) (keys (ns-map ns)))))

May I kindly suggest the inclusion of something similar along with all
the other core namespace functions?
It's quite nice (IMHO: necessary) to be able to get back to a clean
environment when you face a collision error.
(I'm guessing may of you have something similar already defined in
your environments.)

cheers,

Stuart Sierra

unread,
Sep 12, 2010, 3:21:01 PM9/12/10
to Clojure
This will help with collisions, but note that other namespaces may
still hold references to the values of the un-mapped Vars.
-S

Stuart Sierra

unread,
Sep 12, 2010, 3:22:08 PM9/12/10
to Clojure
There's also "remove-ns" in core, which, when followed by "ns", will
have the same effect.
-S

On Sep 11, 9:48 pm, blais <martin.bl...@gmail.com> wrote:

Phil Hagelberg

unread,
Sep 12, 2010, 4:18:16 PM9/12/10
to clo...@googlegroups.com

I've had this on my todo list for swank-clojure for a while now; would
love to see a patch that integrates it. Not sure it belongs in
clojure.core though.

-Phil

Robert McIntyre

unread,
Sep 12, 2010, 4:52:09 PM9/12/10
to clo...@googlegroups.com
shouldn't we rename remove-ns to ns-remove to keep it in line with the
other ns functions?

--Robert McIntyre

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

Laurent PETIT

unread,
Sep 13, 2010, 3:39:29 AM9/13/10
to clo...@googlegroups.com
Yes.

And you should consider wrapping the call to map into (dorun) so that you're sure that once the function exits, all the ns-umap calls are done.

2010/9/12 Robert McIntyre <r...@mit.edu>

Meikel Brandmeyer

unread,
Sep 13, 2010, 4:13:52 AM9/13/10
to Clojure
Hi,

On 13 Sep., 09:39, Laurent PETIT <laurent.pe...@gmail.com> wrote:

> And you should consider wrapping the call to map into (dorun) so that you're
> sure that once the function exits, all the ns-umap calls are done.

> > >> (defn ns-unmap-all
> > >>  "Unmap all the symbols (except 'ns' and 'in-ns')."
> > >>  ([] (ns-unmap-all *ns*))
> > >>  ([ns] (map #(ns-unmap ns %) (keys (ns-map ns)))))

In fact you should use doseq. dorun is so ugly.

Sincerely
Meikel

Laurent PETIT

unread,
Sep 13, 2010, 4:19:20 AM9/13/10
to clo...@googlegroups.com
indeed

2010/9/13 Meikel Brandmeyer <m...@kotka.de>

--
Reply all
Reply to author
Forward
0 new messages