Search code examples
clojurescript

Why is eval not bound in REPL?


I'm learning clojure, I'm trying to experiment in the clojure REPL using shadow-cljs. I thought eval was part of the clojure.core, but using this

(eval (list + 1 2))

produces Error: cljs.core/*eval* not bound

I also tried this but got the same error

(require `clojure.core)
(clojure.core/eval (list + 1 2))

Why is this?


Solution

  • You are likely using a ClojureScript REPL where eval only works as part of self-hosted builds which require additional setup. clojure.core is automatically aliased to cljs.core as part of the compiler, that is why you get the cljs.core/*eval* error.

    If you intend to do actual Clojure REPL work you should use

    shadow-cljs clj-repl
    

    which will give you a pure Clojure REPL.