我引用了ClojureScript clojure.set?并且只能获取文档字符串,但实际运行任何clojure.set
函数都不起作用。在Opera 28.0上使用ClojureScript 0.0-3126和/或在Windows 7 x64上使用Chrome 41.0.2272.101 m。
有关如何纠正此问题的任何想法? 感谢
ClojureScript:cljs.user> (require '[clojure.set])
nil
ClojureScript:cljs.user> (doc clojure.set/union)
-------------------------
clojure.set/union
([] [s1] [s1 s2] [s1 s2 & sets])
Return a set that is the union of the input sets
nil
ClojureScript:cljs.user> (clojure.set/union #{:a} #{:b})
TypeError: Cannot read property 'union' of undefined
TypeError: Cannot read property 'union' of undefined
at eval (eval at <anonymous> (http://localhost:8888/js/coreweb.js:45250:260), <anonymous>:1:100)
at eval (eval at <anonymous> (http://localhost:8888/js/coreweb.js:45250:260), <anonymous>:9:3)
at eval (ev al at <anonymous> (http://localhost:8888/js/coreweb.js:45250:260), <anonymous>:14:4)
at http://localhost:8888/js/coreweb.js:45250:255
at clojure$browser$repl$evaluate_javascript (http://localhost:8888/js/coreweb.js:45256:4)
at Object.callback (http://localhost:8888/js/coreweb.js:45421:181)
at goog.messaging.AbstractChannel.deliver (http://localhost:8888/js/coreweb.js:42499:13)
at goog.net.xpc.CrossPageChannel.xpcDeliver (http://localhost:8888/js/coreweb.js:43463:14)
at Function.goog.net.xpc.NativeMessagingTransport.messageReceived_ (http://localhost:8888/js/coreweb.js:42859:13)
at Object.goog.events.fireListener (http://localhost:8888/js/coreweb.js:39835:21)
答案 0 :(得分:1)
这是个人研究而不是答案。尽管如此,我确实使用ClojureScript Quick Start在Chrome(在MAC上)重现了您的问题。
如果cljs服务器repl文件如下(即require
上没有clojure.set
):
(ns hello-world.core
(:require [clojure.browser.repl :as repl]))
(defonce conn
(repl/connect "http://localhost:9000/repl"))
(enable-console-print!)
(println "Hello world!")
而repl.clj
是:
(require 'cljs.repl)
(require 'cljs.closure)
(require 'cljs.repl.browser)
(cljs.closure/build "src"
{:main 'hello-world.core
:output-to "out/main.js"
:verbose true})
(cljs.repl/repl (cljs.repl.browser/repl-env)
:watch "src"
:output-dir "out")
然后在终端中使用以下命令启动repl:
rlwrap java -cp cljs.jar:src clojure.main repl.clj
在http://localhost:9000
上连接浏览器,然后就可以了:
ClojureScript:cljs.user> (require '[clojure.set])
nil
ClojureScript:cljs.user> (clojure.set/union #{6} #{9} #{7})
#{7 6 9}
现在,如果您重新加载服务器页面http://localhost:9000
,然后重试,我遇到了问题(符号上提供了doc,但< em> var 不再存在了):
ClojureScript:cljs.user> (doc clojure.set/union)
-------------------------
clojure.set/union
([] [s1] [s1 s2] [s1 s2 & sets])
Return a set that is the union of the input sets
nil
ClojureScript:cljs.user> (clojure.set/union #{6} #{9} #{7})
TypeError: Cannot read property 'union' of undefined
TypeError: Cannot read property 'union' of undefined
at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:42:272), <anonymous>:1:100)
如果您将cljs服务器文件修改为require
clojure.set
,即
(ns hello-world.core
(:require [clojure.browser.repl :as repl]
[clojure.set]))
然后,看起来你仍然需要从repl中要求clojure.set才能使用它的功能,但是,你可以重新加载服务器页面,它仍然在repl中工作。