Code
module Mod1
export @Mac1
macro Mac1(name::Symbol, moreslots::Integer=0)
quote
struct $name
filed1::UInt8
field2::UInt16
$(moreslots > 0 ?
quote
field3::UInt32
$name() = new(0,0,0)
end :
quote
$name() = new(0,0)
end)
end
end
end
end
@macroexpand Mod1.@Mac1 STR2 1
I get:
...
field2::Main.Mod1.UInt16
begin
Main.Mod1.field3::Main.Mod1.UInt32
If I escape inner quote
...
esc(quote
field3::UInt32
$name() = new(0,0,0)
end) :
...
then I get
...
begin
field3::UInt32
...
Why I need escaped inner quote?