1

I've referenced ClojureScript clojure.set? and can only get the docstring to come up, but actually running any of the clojure.set function doesn't work. Using ClojureScript 0.0-3126 on Opera 28.0 and/or Chrome 41.0.2272.101 m on Windows 7 x64.

Any ideas on how to correct this? thanks

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)
1
  • This is a weird error you are getting. After following the instructions here for getting a working REPL I get no errors when evaluating the code you posted. Granted I didn't try the specific ClojureScript version you mentioned, I just downloaded the jar linked in that guide, so it might be an bug in the 0.0-3126 version. Commented Mar 25, 2015 at 15:46

1 Answer 1

1

That's more personal research than an answer. Still, I did reproduce your problem in Chrome (on MAC) taking the ClojureScript Quick Start.

If the cljs server repl file is as follow (i.e. there is no require on 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!")

and the repl.clj is:

(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")

Then starting the repl in a terminal with:

rlwrap java -cp cljs.jar:src clojure.main repl.clj

And connecting the browser on http://localhost:9000, then this works:

ClojureScript:cljs.user> (require '[clojure.set])
nil
ClojureScript:cljs.user> (clojure.set/union #{6} #{9} #{7})
#{7 6 9}

Now, if you reload the server page http://localhost:9000, and try again, I had the problem (doc is available on the symbol, but the var is not there anymore):

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)

If you modify the cljs server file to require clojure.set, i.e

(ns hello-world.core
      (:require [clojure.browser.repl :as repl]
                [clojure.set]))

Then, it looks like you still need to require clojure.set from the repl in order to use its functions, but then, you can reload the server page and it still works in the repl.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.