Last active
December 10, 2015 01:18
-
-
Save brandonbloom/4356706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/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