Here is my fourth attempt: (defmacro servlet [servlet-name & meths] `(reify Servlet (for [meth ~meths] (let [[method-name args & body] ~meth camel-case-method-name (hyphenated->camel-case ~method-name)] (camel-case-method-name ~args ~@body)))))
Still it is not working :( How to fix it? On Tuesday, June 18, 2013 12:04:50 AM UTC+2, Gary Trakhman wrote: > > Unquoting 'camel-case-method-name' is going to try and replace the symbol > with it's value during compile-time in the context of the macro itself. > > also, reify isn't going to work if you need a named class to actually wire > up your servlet, for example with a web.xml. Also, consider that you'll > need some AOT compilation for the container to actually see the servlet > class. > > > On Mon, Jun 17, 2013 at 4:38 PM, Hussein B. <hubag...@gmail.com<javascript:> > > wrote: > >> Hi, >> >> My target is to have something like this: >> >> (servlet "ArticlesServlet" >> (do-get [this request response] >> (println "Get Request")) >> (do-post [this request response] >> (println "Post Request"))) >> >> >> I started with this: >> >> (defmacro servlet [servlet-name meths] >> `(reify Servlet >> (for [meth ~@meths] >> (let [[method-name params & body] meth >> camel-case-method-name (hyphenated->camel-case method-name)] >> (~camel-case-method-name ~@body))))) >> >> But of course, it is not working :) >> >> I get: >> >> CompilerException java.lang.RuntimeException: Unable to resolve symbol: >> camel-case-method-name in this context >> >> Why? >> >> And of course, feel super free to correct my Macro :) >> >> Thanks for help and time. >> >> -- >> -- >> 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/groups/opt_out. >> >> >> > > -- -- 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/groups/opt_out.