使用自定义命名空间中的核心功能

时间:2014-01-21 06:44:35

标签: clojure

我正在尝试refer以及来自自定义命名空间的qualify基本核心功能,但没有运气:

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) 

我确信这里有一些简单的事情,有人可以提出建议吗?

2 个答案:

答案 0 :(得分:2)

您应该refer clojure.repl使用doc宏。

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

答案 1 :(得分:1)

首先(use clojure.repl),然后尝试(doc memoize)