# Is there a difference between these 2 pieces of code?

**URL:** <https://discourse.julialang.org/t/is-there-a-difference-between-these-2-pieces-of-code/33255>\
**Category:** General Usage\
**Created:** [January 12, 2020, 12:26am UTC](https://discourse.julialang.org/t/is-there-a-difference-between-these-2-pieces-of-code/33255 "2020-01-12T00:26:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [January 12, 2020, 12:26am UTC](https://discourse.julialang.org/t/is-there-a-difference-between-these-2-pieces-of-code/33255/1 "2020-01-12T00:26:25Z")

</div>

```julia
struct MM
           abstract type TT end
           export TT
           MM() = new()
       end

```

vs

```julia
           abstract type TT end
           export TT
           struct MM end

```

Thanks?

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [January 12, 2020, 3:10am UTC](https://discourse.julialang.org/t/is-there-a-difference-between-these-2-pieces-of-code/33255/2 "2020-01-12T03:10:19Z")

</div>

Why would you write the first code? You can see what code is lowered to using `Meta.@lower, @code_lowered`

---

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [January 12, 2020, 3:46am UTC](https://discourse.julialang.org/t/is-there-a-difference-between-these-2-pieces-of-code/33255/3 "2020-01-12T03:46:55Z")

</div>

```julia
:($(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

```julia
:($(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
))))

```
