【问题标题】:Using core functions from a custom namespace使用自定义命名空间中的核心函数
【发布时间】:2014-01-21 06:44:34
【问题描述】:

我正在尝试 referqualify 自定义命名空间中的基本核心功能,但没有运气:

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) 

我确定这里发生了一些简单的事情,有人可以建议吗?

【问题讨论】:

    标签: clojure


    【解决方案1】:

    您应该 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
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-08-20
        • 2013-11-19
        • 1970-01-01
        • 1970-01-01
        • 2012-01-20
        • 1970-01-01
        • 1970-01-01
        • 2022-01-22
        相关资源
        最近更新 更多