Julians,
I have a question about the construction of the type Expr.
I would like to create a macro to generate types.
julia> a = :(type FooBar{T<:Number}
a::T
b::T
end)
:(type FooBar{T<:Number} # line 2:
a::T # line 3:
b::T
end)
julia> dump(a)
Expr
head: Symbol type
args: Array(Any,(3,))
1: Bool true
2: Expr
head: Symbol curly
args: Array(Any,(2,))
1: Symbol FooBar
2: Expr
head: Symbol <:
args: Array(Any,(2,))
typ: Any
typ: Any
3: Expr
head: Symbol block
args: Array(Any,(4,))
1: LineNumberNode
line: Int64 2
2: Expr
head: Symbol ::
args: Array(Any,(2,))
typ: Any
3: LineNumberNode
line: Int64 3
4: Expr
head: Symbol ::
args: Array(Any,(2,))
typ: Any
typ: Any
typ: Any
My first question is why is args[1] = true?
Why can I not see a::T and b::T or the T<:Number?
I'm inclined to think this is bad form to generate types in macros. I am
trying to create a package for bounding boxes. I'd like to do something
like
@boundingbox BoundsXYZ, "x", "y", "z"
and get the type and method definitions.