(defmacro encode [get-key]       
  (let [body (eval get-key)]     
    `(~@body)))                  


It turns out this is actually the macro I'm looking for, but I still don't 
want to use eval :(

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?

Imagine I have a config of strings and ints. I'm building some strings 
based on the config and it can change. But now I have a list of different 
kinds of configs and I need to do parsing with them. 

For example:
(def config {:delimiter "_"})

;;;...elsewhere in code

(map #(s/join (:delimiter config) %)  strings)



Looks well and good, but happens when I have a list of configs and the 
strings don't join together the same way at all, and they all depend on 
different parts of state of the function in which you're joining them? 

Well, that's why I chose to do something like this


(def config1                                                                
            
  {:key `(str "do something horrible complicated here" (:blah ~'state) 
(:key ~'other-state) (:something ~'evenmorestate)
})
                                                                            
                           
(defmacro encode [ncode get-key]           
  (let [body (eval get-key)]               
    `(~@body)))       

so that I can 
(encode  (:key config1))



instead of something like this
(encode ((:key config1) args args args args args args))

because I want to inline the code to be interpreted once it's inline. 

So is there a way to do this new encode macro without eval? 
(let [body (eval get-key)]...) 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to