Last active
December 10, 2015 23:21
-
-
Save mjg123/a1dca856cd08682f5676 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
(when (not (find-ns 'mattermost)) | |
(.setDynamic ;; <- This horrific interop into Var.java to counter | |
(intern (create-ns 'mattermost) ;; CLJ-951, which is a closed/wishlist bug reporting that | |
(with-meta '*me* {:dynamic true}) ;; <- this is actually not propagated fully (is, in fact, useless) :( | |
"foo"))) | |
(defn eval-w-bindings [str user] | |
(binding [*ns* (create-ns 'mattermost) | |
mattermost/*me* user] | |
(clojure.core/refer 'clojure.core) | |
(-> str read-string eval))) | |
(eval-w-bindings "(str \"hello \" *me*)" "andrew") | |
;; => "hello andrew" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is what I wanted:
And the above code has does it! Yay! But I'd also like to be able to pass in the namespace instead of hard-coding
mattermost
everywhere.