Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RuntimeException when using queue literal in REPL

So I'm just beginning my clojurescript experience, and following along with the clojurescript-unraveled web book to get down the basics. Been a smooth process mostly, but I've hit a snag using the #queue [] literal. I'm using alein repl running Clojure 1.8.0, Java 1.8.0_112-b16, and Leiningen 2.7.1.

When I put in the following input:

(def pq #queue [1 2 3])

I get this stacktrace:

RuntimeException No reader function for tag queue  
clojure.lang.LispReader$CtorReader.readTagged (LispReader.java:1245)
RuntimeException Unmatched delimiter: )  
clojure.lang.Util.runtimeException (Util.java:221)

I've tried the #js tag literal as well, and got the same No reader function for tag ... exception. However, the UUID and instance of time literals work as expected with no runtime errors.

I'm in the process of digging into this problem and am now in the realm of exploring the broader topics of the edn spec and the cljs.reader implementation, but I'm not making a whole lot of progress on solving the original problem. Any insight on why this exception is/might be occurring would be much appreciated.

Thanks.

like image 478
jchaffin Avatar asked Apr 16 '26 17:04

jchaffin


2 Answers

The #queue [] syntax exists in clojurescript, but not in JVM clojure. You can refer to clojure.lang.PersistentQueue/EMPTY, which is an empty queue.

like image 128
amalloy Avatar answered Apr 18 '26 07:04

amalloy


The #queue literal only exists in ClojureScript, so a REPL with Clojure proper cannot resolve it. Other (e.g., #uuid) literals exist in both. Since the common literals work, but #queue does not, this would suggest that you are in fact running a Clojure REPL instead of CLJS REPL.

clojurescript-unraveled provides instructions for setting a REPL with Nashorn, Node.js, or Browser. Another option is to use a figwheel REPL, which connects to a browser.

like image 21
Toni Vanhala Avatar answered Apr 18 '26 06:04

Toni Vanhala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!