I’d like to obtain the code
struct S{𝒯<:Real}
end
programmatically. Method 1 below works, but I’d like to be able to feed in the variable name (here S
) automatically (e.g. by passing a variable x
containing :S
) and hence to construct a single symbol out of the concatenation of x
and {𝒯<:Real}
. How do I accomplish this? The curlies appear to be the culprit here; see methods 2 through 4 below.
name₁ = :(S₁{𝒯<:Real})
name₂ = Symbol( :S₂, :({𝒯<:Real}) )
name₃ = Symbol( :S₃, :T )
name₄ = Symbol( "S₄{𝒯<:Real}" )
e₁ = Expr( :struct, false, name₁, Expr( :block ) )
e₂ = Expr( :struct, false, name₂, Expr( :block ) )
e₃ = Expr( :struct, false, name₃, Expr( :block ) )
e₄ = Expr( :struct, false, name₄, Expr( :block ) )
eval( e₁ )
eval( e₂ )
eval( e₃ )
eval( e₄ )
dump( e₁ )
dump( e₂ )
dump( e₃ )
dump( e₄ )
names( Main )