johnbakers
johnbakers

Reputation: 24771

Using core functions from a custom namespace

I am trying to refer and alternately qualify basic core functions from a custom namespace, without luck:

cplay.core> (refer 'clojure.core)
nil
cplay.core> (clojure.core/refer 'clojure.core)
nil
cplay.core> (doc memoize)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: doc in this context, compiling:(/private/var/folders/0h/lzx021jx1rl95vhfxmcppmlc0000gn/T/form-init7998067657898575130.clj:1:1) 
cplay.core> (clojure.core/doc memoize)
CompilerException java.lang.RuntimeException: No such var: clojure.core/doc, compiling:(/private/var/folders/0h/lzx021jx1rl95vhfxmcppmlc0000gn/T/form-init7998067657898575130.clj:1:1) 

I'm sure there is something simple here going on, can anyone advise?

Upvotes: 0

Views: 118

Answers (2)

llj098
llj098

Reputation: 1412

first (use clojure.repl) and then try (doc memoize)

Upvotes: 1

ntalbs
ntalbs

Reputation: 29458

You should refer clojure.repl to use doc macro.

user=> (ns xxx)
nil
xxx=> (clojure.repl/doc memoize)
-------------------------
clojure.core/memoize
([f])
  Returns a memoized version of a referentially transparent function. The
  memoized version of the function keeps a cache of the mapping from arguments
  to results and, when calls with the same arguments are repeated often, has
  higher performance at the expense of higher memory use.
nil
xxx=> (refer 'clojure.repl)
nil
xxx=> (doc memoize)
-------------------------
clojure.core/memoize
([f])
  Returns a memoized version of a referentially transparent function. The
  memoized version of the function keeps a cache of the mapping from arguments
  to results and, when calls with the same arguments are repeated often, has
  higher performance at the expense of higher memory use.
nil

Upvotes: 2

Related Questions