Just puzzling over this simple problem I'm having while learning about 
macros. Here's an expression:

julia> e = quote
       a = 2
       b  = 3
       end

quote  # none, line 2:
    a = 2 # line 3:
    b = 3
end


If I go through this simply, I'll get a crack at each element of the args 
array: 

 

julia> for i in e.args
       println("the arg is ", i)
       end

 

the arg is  # none, line 2:
the arg is a = 2
the arg is  # line 3:
the arg is b = 3


If I try to write a macro:
 

julia> macro my(exp)
                  for i in exp.args
                      println("the arg is ", eval(i))
                  end
              end

and call it like this:
 

julia> @my :e
the arg is begin  # none, line 2:
    a = 2 # line 3:
    b = 3
end


it does all the elements at once.

It's probably a simple thing, but I could do with a hint!

cheers

Reply via email to