As Carlo said, we need to keep track of when things are running. Within the
context of any given unquote, for instance ~@(for [meth meths] ...), we're
actually executing code. So if you don't quote the
expression `(~method-name ~args ~@body), you (1) will try to execute the
function "method-nam
Here are some talks I really liked for understanding macros:
http://www.infoq.com/presentations/Clojure-Macros
http://www.youtube.com/watch?v=0JXhJyTo5V8
On Tue, Jun 18, 2013 at 3:47 AM, Hussein B. wrote:
> I don't get why we have to use a second 'back tick'. I thought one
> backtick at the be
I don't get why we have to use a second 'back tick'. I thought one backtick
at the beginning and then we use ~ and ~@ when needed.
On Tuesday, June 18, 2013 2:09:44 AM UTC+2, Carlo wrote:
>
> I can't speak to the issues that Gary raised, but I can help you with your
> macro.
>
> (defmacro servle
I can't speak to the issues that Gary raised, but I can help you with your
macro.
(defmacro servlet [servlet-name & meths]
`(reify Servlet
~@(for [meth meths]
(let [[method-name args & body] meth
method-name (hyphenated->camel-case method-name)]
`(~method-
here's a starting point:
https://github.com/mmcgrana/ring/blob/master/ring-servlet/src/ring/util/servlet.clj#L149
On Mon, Jun 17, 2013 at 6:12 PM, Hussein B. wrote:
> Here is my fourth attempt:
>
> (defmacro servlet [servlet-name & meths]
> `(reify Servlet
> (for [meth ~meths]
>(
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
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