(def dict
{:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
(defmacro my-macro [obj & args]
`(print ~(:key dict) ~@args))
(macroexpand '(my-macro {:blah "thingy"} "test string"))
(def dict
{:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
(defmacro my-macro [my-obj & args]
`(let [obj my-obj]
(print ~(:key dict) ~@args))
(macroexpand '(my-macro {:blah "thingy"} "test string"))
(def dict
{:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
(defmacro my-macro [obj & args]
`(let [o# ~obj
a# ~args]
(apply (fn [obj args] (print ~(:key dict) args)) o# a#)))
(def dict {:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
(defmacro my-macro [inobj & args] `(let [~'obj ~inobj] (print ~(:key dict) ~@args)))
(macroexpand '(my-macro {:blah "thingy"} "test string"))
(def dict
{:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
(defmacro my-macro [my-obj & args]
`(let [~'obj ~my-obj]
(print ~(:key dict) ~@args)))
(my-macro {:blah "thingy"} "test string")
;; obj isn't defined in this scopethingy test string
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
(def dict {:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
(defmacro encode [my-obj body] `(let [~'obj ~my-obj] ~body))
(macroexpand '(encode {:blah "thingy"} (:key dict))) => (let* [code (first json)] (:key dict))
(encode {:blah "thingy"} (:key dict)))
(clojure.core/str "obj isn't defined in this scope" (:blah obj))
(def dict {:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
(defmacro encode [ncode get-key]
(let [body (eval get-key)]
`(let [~'code ~ncode]
~body)))
(macroexpand '(encode {:blah "thingy"} (:key dict)))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/exOJKNWC-a4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
(defmacro encode [get-key]
(let [body (eval get-key)]
`(~@body)))
Honestly, it looks to me that you are concocting something overly complicated. Are you sure that a combination of anonymous functions and dynamic variables won't suffice? Can you, in broad strokes, describe what you want to achieve?
(def config {:delimiter "_"})
;;;...elsewhere in code
(map #(s/join (:delimiter config) %) strings)
(encode (:key config1))
(encode ((:key config1) args args args args args args))
(let [body (eval get-key)]...)
(def config1
{:key (fn [] (str "do something horrible complicated here" (:blah state) (:key other-state) (:something evenmorestate)))})
;; To invoke:
((:key config1))