lisp - clojure - resolve a symbol inside let -
how write function resolve symbol in lexical environment?
(let [foo some-var] (let [sym 'foo] (resolve-sym sym)))
i want var 'foo bound to.
i not sure why want this, looks can done. http://clojuredocs.org/circumspec/circumspec.should/local-bindings
(defmacro local-bindings "produces map of names of local bindings values. now, strip out gensymed locals. todo: use 1.2 feature." [] (let [symbols (remove #(.contains (str %) "_") (map key @clojure.lang.compiler/local_env))] (zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols))) (let [foo 1 bar 2] (local-bindings)) => {foo 1, bar 2}
Comments
Post a Comment