That's cool.  Thanks!

On Fri, Sep 6, 2013 at 7:17 AM, Phillip Lord
<phillip.l...@newcastle.ac.uk>wrote:

>
> Mark <markaddle...@gmail.com> writes:
>
> > I find the vast majority of the time I'm tempted to write a macro (yeah,
> > yeah, I know the first rule of macro club), is to defn-like things.
> > Writing a defn-like macro to handle all the stuff defn does is pretty
> tough
> > so I end up writing a barebones thing that doesn't support doc-string,
> > doesn't support multiple arities, and doesn't support metadata.  I'm
> > wondering, has anyone written a defdefnmacro macro?
>
> For this, I just use defn. For example, this macro is like defn, but
> also takes a function as the second argument. It composes the body with
> function.
>
> (defmacro defnwithfn [name function & body]
>   `(let [vr# (defn ~name ~@body)]
>      (alter-var-root
>       vr#
>       (fn [f#]
>         (fn ~name [& args#]
>           (apply ~function f# args#))))
>      vr#))
>
> Basically, you let defn do the work, then fiddle with it after.
>
> Phil
>
> --
> --
> 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 a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/fu3-n_iFLuk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> 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.

Reply via email to