your version is obviously wrong, when '~param will try to resolve param, 
but no luck

On Saturday, December 24, 2016 at 10:07:15 PM UTC+8, Jim foo.bar wrote:
>
> try the following:
>
> (defmacro defapihandler [handler-name params & body]
>   `(defn ~handler-name ['~passed-param]
>      (let [param-keys# (vec (map (comp symbol name :key)
>                                 ~params))
>            {:keys param-keys#} '~passed-param]
>        ;; some check
>        ~@body)))
>
>
>
> Sorry for brevity, I'm on my phone...
> Dimitris
>
> On 24/12/16 13:23, Jiacai Liu wrote:
>
> I don’t think your answer is correct. From the expaned macro
>
> (defn create-user [passed-param__10243__auto__]
>   (let [param-keys__10244__auto__ (vec
>                                     (map
>                                       (comp symbol name :key)
>                                       [{:key :username,
>                                         :checkers []}]))
>         {:keys param-keys__10244__auto__} passed-param__10243__auto__]
>     (do (println username))))
>
> and following test
>
> (let [some-keys '[a b]
>       {:keys some-keys} {:a 1 :b 2}]
>   ; thows Don't know how to create ISeq from: clojure.lang.Symbol
>   (println a b))
>
> (let [{:keys [a b]} {:a 1 :b 2}]
>   ; ok
>   (println a b))
>
> I think it is in let destructuring form, we can’t use dynamic var to 
> represent symbols
>
>
>
> On Saturday, December 24, 2016 at 8:43:42 PM UTC+8, Jim foo.bar wrote: 
>>
>> you need to use `'~passed-param` in your arg-vector, and the same 
>> whenever you use it inside the newly defined fn.
>>
>>
>> HTH,
>>
>> Dimitris
>>
>> On 24/12/16 11:48, Jiacai Liu wrote:
>>
>> how to make correct fn args when create fn using macro
>> http://stackoverflow.com/q/41312963/2163429?sem=2
>> -- 
>> 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.
>>
>>
>> -- 
> 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 <javascript:>
> 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 <javascript:>
> 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 <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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