Good stuff. You might also mention that when you actually switch to a
namespace using the ns macro, clojure gets referred, giving you a
bunch more stuff:
(create-ns 'test)
#=(find-ns test)
user=> (count (ns-map 'test))
96
user=> (ns test)
nil
test=> (ns user)
nil
user=> (count (ns-map 'test))
513
Cheers,
Stuart
Thanks, that's good to know - I didn't realize the ns macro did that!
I just had a look at the docstring for ns:
"Sets *ns* to the namespace named by name (unevaluated), creating it
if needed. references can be zero or more of: (:refer-clojure ...)
(:require ...) (:use ...) (:import ...) (:load ...) with the syntax
of refer-clojure/require/use/import/load respectively, except the
arguments are unevaluated and need not be quoted. If :refer-clojure
is not used, a default (refer 'clojure) is used. Use of ns is preferred
to individual calls to in-ns/require/use/import:
(ns foo
(:refer-clojure :exclude [ancestors printf])
(:require (clojure.contrib sql sql.tests))
(:use (my.lib this that))
(:import (java.util Date Timer Random)
(java.sql Connection Statement))
(:load \"/mystuff/foo.clj\"))"
It appears that ns provides a lot of "convenience" functionality!
Cheers,
Bill
Thanks for the clarifications - I've updated my blog post to use "var"
instead of "symbol" and I've added both your comments and Stuart's
comments as updates to the blog post.
Bill
Your backslashes have gone missing in your calls to printf. e.g.:
(doseq x (ns-map 'test) (printf "%s: %sn" (first x) (frest x)))
--
Michael Wood <esio...@gmail.com>
Arrggh! I hate it when that happens! I forget to escape backslashes in
PRE blocks way too often. Thanks for letting me know.
- Bill