Presumably you need an esc around the exp. See the metaprogramming chapter.

--Tim

On Friday, December 18, 2015 04:02:08 PM 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/pairwi
> selistmatrix.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/gbLA
> 6s86P90/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