Since the bindings are a function of the data that's passed in, IMO
you don't need a anaphoric macro for this.
For example -
(defmacro def-names [names & body]
(let [bindings* (vec (mapcat (juxt symbol identity) names))]
`(let ~bindings*
~@body)))
As to whether it's a good idea or not, I'd say it depends but YMMV.
Regards,
BG
On Tue, Jul 23, 2013 at 12:48 PM, <[email protected]> wrote:
> Hi,
> I want to write a macro that introduces new variables from data.
> The data is a vector and looks like this for example: ["a" "b" "c"]
>
> I want to use the macro like this:
> (def-names ["a" "b" "c"] (str a b))
>
> What code I want the macro to produce from the above is the following:
> (let [a "a"
> b "b"
> c "c"]
> (str a b))
>
> Is it possible to do that?
> Is it a good thing to do that or is it bad practice?
>
> Thanks
> --anders
>
>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
Baishampayan Ghose
b.ghose at gmail.com
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.