Clojure Notes 3


Context: Studying the short Clojure program at

(ns forth
   (:refer-clojure :exclude [pop!]))

This imports all of clojure.core except for pop!, which the author wants to redefine. Here's the definition of refer:


    * (refer 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.

The definition of refer-clojure:


    * (refer-clojure & filters)

Same as (refer 'clojure.core )

assoc on vectors. Remember that assoc can be used with maps or vectors. When used on a vector, assoc can replace an existing value or add a new value to the end (e.g., a fourth value to a vector with three values), but not beyond (will give an error).

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License