To create a type at runtime, there are a few of methods - each delivering 
an equivalent result:


*julia> quote*
*       type Test1*
*           a1::Int32*
*           a2::Int32*
*           a3::Int32*

*       end*
*   end*
quote  # none, line 2:
    $(Expr(:type, true, :Test1, quote  # line 3:
        a1::Int32 # line 4:
        a2::Int32 # line 5:
        a3::Int32
    end))
end

*julia> parse("""quote*
*       type Test2*
*           a1::Int32*
*           a2::Int32*
*           a3::Int32*

*       end*
*   end""")*
quote  # none, line 2:
    $(Expr(:type, true, :Test2, quote  # line 3:
        a1::Int32 # line 4:
        a2::Int32 # line 5:
        a3::Int32
    end))
end


*julia> Expr(:type, false, symbol("Test3"), Expr(:block, [Expr(:(::), 
symbol("a$x"), symbol("Int32")) for x = 1:3]...))*
:($(Expr(:type, false, :Test3, quote
        a1::Int32
        a2::Int32
        a3::Int32
    end)))

*Question:* I'm interested if there is a better quote method, something 
that avoids playing with string parsing or explicit Expr()'s with some 
ninja $() magic like pseudo-code:

*quote*
*    type Test4*
*        $for x = 1:3*
*            a$x::Int32*
*        $end*
*    end*
*end*

Anything similar actually possible?

Reply via email to