Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
clojure需要isn';t设置名称空间oauth_Clojure - Fatal编程技术网

clojure需要isn';t设置名称空间oauth

clojure需要isn';t设置名称空间oauth,clojure,Clojure,如何测试require是否在clojure中工作。REPL中的Require返回nil。我不知道零是否意味着它起作用了。oauth的名称空间似乎未设置 错误 原因:java.lang.RuntimeException:没有这样的命名空间:oauth (ns hello.core) (defn -main [] (require 'twitter '[oauth.client :as oauth]) ;; Make a OAuth consumer (def oauth-con

如何测试require是否在clojure中工作。REPL中的Require返回nil。我不知道零是否意味着它起作用了。oauth的名称空间似乎未设置

错误

原因:java.lang.RuntimeException:没有这样的命名空间:oauth

(ns hello.core)
(defn -main
  []

  (require 'twitter '[oauth.client :as oauth])

  ;; Make a OAuth consumer
  (def oauth-consumer (oauth/make-consumer <key>
                                           <secret>
                                           "https://api.twitter.com/oauth/request_token"
                                           "https://api.twitter.com/oauth/access_token"
                                           "https://api.twitter.com/oauth/authorize"
                                           :hmac-sha1))
(ns hello.core)
(defn-main)
[]
(需要“twitter”[oauth.client:作为oauth])
做一个真正的消费者
(def oauth耗电元件(oauth/make耗电元件
"https://api.twitter.com/oauth/request_token"
"https://api.twitter.com/oauth/access_token"
"https://api.twitter.com/oauth/authorize"
:hmac-sha1)

require
放在
-main
函数中不起作用;必须在文件求值时求值,才能识别名称空间别名。您应该将其放在
ns
表单中:

(ns hello.core
  (:require [oauth.client :as oauth]
            [twitter]))

require
放在
-main
函数中不起作用;必须在文件求值时求值,才能识别名称空间别名。您应该将其放在
ns
表单中:

(ns hello.core
  (:require [oauth.client :as oauth]
            [twitter]))

要添加到Sam的答案中,请注意repl环境和.clj文件中的不同

要添加到Sam的答案中,请注意repl环境和.clj文件中的差异

(ns hello.core)(需要文档中的“twitter”[oauth.client:as oauth])@glochild:“在
ns
宏中使用
:需要
,而不是直接调用它。”(ns hello.core)(需要文档中的“twitter”[oauth.client:as oauth])@glochild:“使用
:在
ns
宏中要求
,而不是直接调用此宏。”