Re: Trouble with advanced macros

2019-03-30 Thread Alexander Yakushev
No, I still don't get it. Why wouldn't this work? (def config1 {:key (fn [] (str "do something horrible complicated here" (:blah state) (:key other-state) (:something evenmorestate)))}) ;; To invoke: ((:key config1)) -- You received this message because you are subscribed to the Google Group

Re: Trouble with advanced macros

2019-03-30 Thread Nathan Rogers
(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 overl

Re: Trouble with advanced macros

2019-03-30 Thread Alexander Yakushev
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? On Sat, Mar 30, 2019, 18:31 Nathan Rogers wrote: > (def dict >

Re: Trouble with advanced macros

2019-03-30 Thread Nathan Rogers
(def dict {:key `(str "obj isn't defined in this scope" (:blah ~'obj))}) (defmacro encode [ncode get-key]

Re: Trouble with advanced macros

2019-03-30 Thread Nathan Rogers
Ok, so it turns out I have other issues. Args is (:keys dict) and that doesn't evaluate (def dict {:key `(str "obj isn't defined in this scope" (:blah ~'obj))})

Re: Trouble with advanced macros

2019-03-29 Thread Nathan Rogers
Thanks everyone. That's what I needed. On Fri, Mar 29, 2019 at 3:25 AM Alexander Yakushev wrote: > Looks like you are missing a few unquotes. Is this what you expected? > > (def dict > {:key `(str "obj isn't defined in this scope" (:blah ~'obj))}) > > (defmacro my-macro [my-obj & args] > `(

Re: Trouble with advanced macros

2019-03-29 Thread Alexander Yakushev
Looks like you are missing a few unquotes. Is this what you expected? (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 de

Re: Trouble with advanced macros

2019-03-29 Thread peterhull90
How about: (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"} "t

Re: Trouble with advanced macros

2019-03-28 Thread Nathan Rogers
(def dict {:key `(str "obj isn't defined in this scope" (:blah ~'obj))}) (defmacro my-macro [obj & args]