Skip to content

Instantly share code, notes, and snippets.

@brandonbloom
Last active December 10, 2015 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonbloom/4356706 to your computer and use it in GitHub Desktop.
Save brandonbloom/4356706 to your computer and use it in GitHub Desktop.
~/Projects/clojurescript (master*) $ rlwrap ./script/repl
Clojure 1.4.0
(require '[cljs.compiler :as comp])
(require '[cljs.analyzer :as ana])
;; This trickery seems to be the minimum logic to prepare a top level namespace
(def repl-env
(binding [ana/*cljs-ns* 'cljs.user]
(-> (ana/empty-env)
(ana/analyze '(ns some-ns))
:env
(assoc :ns (ana/get-namespace ana/*cljs-ns*)))))
(defn analyze [form]
(binding [ana/*cljs-warn-on-undeclared* true]
(ana/analyze repl-env form)))
(-> '(defprotocol P
(f [_ x]))
analyze
keys)
nil
user=> nil
user=> user=> user=> #'user/repl-env
user=> user=> #'user/analyze
user=> user=> WARNING: Use of undeclared Var some-ns/f at line 16
WARNING: Use of undeclared Var some-ns/f at line 16
(:env :op :form :statements :ret :children)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment