Skip to content

clojure.core/refer

View this page on ClojureDocs

Type: function Added: Clojure 1.0 Examples: 3 Runnable: 1
([ns-sym & filters])

refers to all public vars of ns, subject to filters. filters can include at most one each of:

:exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol

For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current namespace. Filters can be used to select a subset, via inclusion or exclusion, or to provide a mapping to a symbol different from the var's name, in order to prevent clashes. Use :use in the ns macro in preference to calling this directly.

Examples

by teyc on
by ryo on . May have evaluation errors.
by ryo on . May have evaluation errors.

Note by KingMob

Warning: the referral of a var isn't transitive.

refer only works with a var's original namespace.

If you refer A/foo from B, you can't then refer B/foo from C.

foo it will appear in B's ns-map, but not ns-publics or ns-interns, unintuitively.

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.