This is a good example of where the MacroTools <https://github.com/one-more-minute/MacroTools.jl> package comes in handy:
@match :(a.b) begin x_.y_ => (x, y) end # (:a, :b) Since you don't have to worry about the internal structure of the expression. On Sun, 26 Jul 2015 at 23:21 David Gold <[email protected]> wrote: > Perhaps it's related to the fact that `getfield` takes a `Symbol` argument: > > > > julia> type MyType > b > end > > julia> a = MyType(10) > MyType(10) > > julia> getfield(a, :b) > 10 > > So you could just do `getfield(x, $(rhs.arg[2]))`. > > On Sunday, July 26, 2015 at 6:00:58 PM UTC-4, Cedric St-Jean wrote: > >> Why is . non-symmetric in a and b? >> >> > :(a.b).args >> >> 2-element Array{Any,1}: >> :a >> :(:b) >> >> >> The second argument is a quotenode, how am I supposed to get to the :b >> inside it? eval works, but in the Lisp world, that was bad style. I've >> got a macro that works on this expression, and instead of >> x.$(rhs.arg[2]) >> >> I have to write >> >> x.$(eval(rhs.arg[2]) >> >> Cédric >> >
