struct MM
abstract type TT end
export TT
MM() = new()
end
vs
abstract type TT end
export TT
struct MM end
Thanks?
struct MM
abstract type TT end
export TT
MM() = new()
end
vs
abstract type TT end
export TT
struct MM end
Thanks?
Why would you write the first code? You can see what code is lowered to using Meta.@lower, @code_lowered
:($(Expr(:thunk, CodeInfo(
@ REPL[28]:2 within `top-level scope'
1 ─ global MM
│ const MM
│ $(Expr(:struct_type, :MM, :(Core.svec()), :(Core.svec()), :(Core.Any), :(Core.svec()), false, 0))
│ global MM
│ global TT
│ const TT
│ $(Expr(:abstract_type, :TT, :(Core.svec()), :(Core.Any)))
│ export TT
│ $(Expr(:method, :MM))
│ %10 = Core.Typeof(MM)
│ %11 = Core.svec(%10)
│ %12 = Core.svec()
│ %13 = Core.svec(%11, %12)
│ $(Expr(:method, :MM, :(%13), CodeInfo(quote
%new(MM)
return %1
end)))
└── return
))))
vs
:($(Expr(:thunk, CodeInfo(
@ REPL[29]:2 within `top-level scope'
1 ─ global TT
│ const TT
│ $(Expr(:abstract_type, :TT, :(Core.svec()), :(Core.Any)))
│ @ REPL[29]:3 within `top-level scope'
│ export TT
│ @ REPL[29]:4 within `top-level scope'
│ global MM
│ const MM
│ $(Expr(:struct_type, :MM, :(Core.svec()), :(Core.svec()), :(Core.Any), :(Core.svec()), false, 0))
│ global MM
│ $(Expr(:method, :MM))
│ %10 = Core.Typeof(MM)
│ %11 = Core.svec(%10)
│ %12 = Core.svec()
│ %13 = Core.svec(%11, %12)
│ $(Expr(:method, :MM, :(%13), CodeInfo(quote
%new(MM)
return %1
end)))
└── return
))))