This works fine if I quote and interpolate *l*:

julia> function test(plm)
              l = []
              @iteratelist plm Base.push!(:($l), list[k])
              l
       end
test (generic function with 1 method)


julia> test(PLM)
3-element Array{Any,1}:
 1
 2
 3




On Friday, December 18, 2015 at 9:02:08 PM UTC-3, Diego Javier Zea wrote:
>
> I defined the macro @iteratelist 
> <https://github.com/diegozea/PairwiseListMatrices.jl/blob/master/src/macros.jl#L1-L27>
>  
> in PairwiseListMatrices. I used a similar macro in function definitions 
> <https://github.com/diegozea/PairwiseListMatrices.jl/blob/master/src/pairwiselistmatrix.jl#L745>
>  
> inside that package without problems. However, the same code doesn't work 
> for function definitions outside that package, like in the example below. 
> Why was *l* expanded as *PairwiseListMatrices.l *? Thanks!
>
>
>
> <https://lh3.googleusercontent.com/-8K2AU8SuRDs/VnScACgeknI/AAAAAAAAOvQ/gbLA6s86P90/s1600/macro.png>
>
> *Code: *
>
> using PairwiseListMatrices
>
> PLM = PairwiseListMatrix([1, 2, 3], false)
>
> function test(plm)
>        l = []
>        @iteratelist plm Base.push!(l, list[k])
>        l
> end
>
> function test_macroexpand(plm)
>        l = []
>        println( macroexpand( quote @iteratelist plm Base.push!(l, list[k]) 
> end))
>        l
> end
>
> test(PLM)
>
> test_macroexpand(PLM)
>
>
>
>

Reply via email to