2013/5/28 ru <soro...@oogis.ru>

> Does (:require [protege.core :refer :all]) is equivalent to (:require
> protege.core)?


No. (:require [protege.core :refer :all]) does roughly the following

 * Loads and compiles proteger.core
 * Stores it in the namespace map as proteger.core, so fn1 in it can be
referred to with the ns prefix,  proteger.core/fn1
 * For every function in proteger.core, creates an alias in the current
namespace (so they can be referred to without the ns prefix, e.g. fn1)

This is exactly what :use was used for before Clojure 1.4. This approach is
known as "naked :use" has a few issues

 * It makes it dead easy to override other functions in the current
namespace, such as those of clojure.core, and not notice or ignore the
warning
 * It is not obvious where does the function come from

(:require protege.core) only loads the namespace but does not perform the
3rd step.

If you want to spare some typing or make some code that uses a DSL look
nicer, you can load a namespace
with an alias

(:require [protege.core :as p])

and then refer to it using the shorter prefix, e.g. p/fn1.

See the clojure-doc.org guide I've linked to.
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to