On Monday, February 10, 2014 03:16:18 AM Fil Mackay wrote: > Is there an equivalent that allows a for loop iterator to construct the > type.. Base.Cartesian.@forexprs perhaps? :)
Base.Cartesian is a slightly-enhanced version of the original Cartesian.jl package; the README there is (in my personal opinion) quite thorough. The version in base is intentionally undocumented since we don't plan on exporting it. But I'm wondering if perhaps you're simply wondering if you can replace "5" in my example with something else. The answer is yes: julia> for N = 1:5 typename = symbol(string("MyType", N)) @eval begin type $typename Base.Cartesian.@nexprs $N i->a_i::Int end end end julia> MyType2.names (:a_1,:a_2) julia> MyType4.names (:a_1,:a_2,:a_3,:a_4)