you can't do what you are proposing, by design. a macro cannot do anything
that you cannot express directly, it simply allows you to express it more
succinctly by templating the redundant parts.

if you want a "set" or "numbered list", use a set or number list. variables
are bad at that sort of task. whereas an Array is very good at it.

On Fri, Mar 6, 2015 at 8:05 AM Abe Schneider <abe.schnei...@gmail.com>
wrote:

> I'm trying to create a set of variables (_1, _2, ...) from items within a
> list in a macro. I have a (much) condensed version of the code:
>
> macro testfn()
>     quote
>         i = 1
>         value = [1, 2, 3]
>         $(Expr(:(=), Expr(:symbol, Expr(:string, "_", :i)), :value))
>         println(_1)
>     end
> end
>
>
> which gives me:
>
> ERROR: syntax: invalid assignment location
>
>
> Any ideas on what might be wrong or the proper way to do this? I would
> like to keep this in the quotes, as in the actual version there's a lot
> more code surrounding the assignment.
>
> I can get things to work with an eval, but I rather avoid the eval, and it
> appears to create a non-local variable.
>
>
> Thanks!
>

Reply via email to