Last active
December 4, 2015 00:40
-
-
Save tolitius/c17b2d4a98eabb591926 to your computer and use it in GitHub Desktop.
cljs: ns-interns vs. ns-interns*
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
;; Bootstrapped ClojureScript | |
;; -------------------------- | |
cljs.user=> (require '[cljs.js :as cljs]) | |
cljs.user=> (def foo 42) | |
#'cljs.user/foo | |
cljs.user=> (cljs/eval-str (cljs/empty-state) "(ns-interns (quote cljs.user))" "interning" {:eval cljs/js-eval} identity) | |
{:ns cljs.user, :value {}} | |
cljs.user=> (cljs/eval-str (cljs/empty-state) "(ns-interns* (quote cljs.user))" "interning" {:eval cljs/js-eval} identity) | |
{:ns cljs.user, :value {foo #'cljs.user/foo}} | |
;; Replumb ClojureScript REPL ( https://github.com/ScalaConsultants/replumb ) | |
;; -------------------------------------------------------------------------- | |
cljs.user=> (require '[replumb.core :as replumb]) | |
cljs.user=> (def foo 42) | |
#'cljs.user/foo | |
cljs.user=> (replumb/read-eval-call {:eval-fn js/eval} identity "(ns-interns* 'cljs.user)") | |
{:success? true, :form (ns-interns* (quote cljs.user)), :value "{foo #'cljs.user/foo}"} | |
cljs.user=> (replumb/read-eval-call {:eval-fn js/eval} identity "(ns-interns 'cljs.user)") | |
{:success? true, :form (ns-interns (quote cljs.user)), :value "{}"} | |
;; Regular ClojureScript REPL | |
;; -------------------------- | |
cljs.user=> (defstate foo :start 42) | |
nil | |
;; corect meta | |
cljs.user=> (-> ((ns-interns 'cljs.user) 'foo) meta) | |
{:mount-state 42, :ns cljs.user, :name foo, :file "<cljs repl>", :end-column 14, :start (clojure.core/fn [] 42), :source "foo", :column 1, :line 1, :status #{:stopped}, :end-line 1, :order 1, :arglists (), :doc nil, :test nil} | |
cljs.user=> | |
;; no meta | |
cljs.user=> (-> ((ns-interns* 'cljs.user) 'foo) meta) | |
{:ns #object[cljs.core.Namespace]} | |
cljs.user=> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to keep the state atom around and use it to build up analysis metadata. In
script/noderepljs
: