# Redefining structure (again).. what' the current situation and what to expect?

**URL:** <https://discourse.julialang.org/t/redefining-structure-again-what-the-current-situation-and-what-to-expect/127859>\
**Category:** General Usage\
**Created:** [April 8, 2025, 4:05pm UTC](https://discourse.julialang.org/t/redefining-structure-again-what-the-current-situation-and-what-to-expect/127859 "2025-04-08T16:05:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [April 8, 2025, 4:05pm UTC](https://discourse.julialang.org/t/redefining-structure-again-what-the-current-situation-and-what-to-expect/127859/1 "2025-04-08T16:05:58Z")

</div>

Recently there have been a lot of discussions about the possibility and the implementations allowing Struct redefinition ([1](https://discourse.julialang.org/t/ann-strucrev-revise-type-definitions-as-you-go/109959), [2](https://discourse.julialang.org/t/thoughts-and-tempering-expectations-on-redefining-structs/101190/36), [3](https://discourse.julialang.org/t/this-month-in-julia-world-2024-05/115278), …) and some related pull requests/issues have been closed ([1](https://github.com/JuliaLang/julia/pull/54654),[2](https://github.com/JuliaLang/julia/issues/40399),…)

So, which is the situation now? Struct redefinition with Revise will just work ( 🤣 )? Will I need Julia 1.12 for it to work, or will I still need another package to add some temporary macro ?

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [April 8, 2025, 4:16pm UTC](https://discourse.julialang.org/t/redefining-structure-again-what-the-current-situation-and-what-to-expect/127859/2 "2025-04-08T16:16:39Z")

</div>

TLDR: [Fix struct/const revision by timholy · Pull Request #894 · timholy/Revise.jl · GitHub](https://github.com/timholy/Revise.jl/pull/894)

For a long while there have been ways to “fake” struct revision by putting things into temporary modules. Pluto.jl can do that for instance and there are other helper packages for stuff like that.

A few months ago, Keno implemented the necessary tracking capabilities in core julia (up until then only method redefinition was tracking in core julia). Support in Revise.jl is trailing a bit, given that this is a big undertaking.

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [April 8, 2025, 4:19pm UTC](https://discourse.julialang.org/t/redefining-structure-again-what-the-current-situation-and-what-to-expect/127859/3 "2025-04-08T16:19:12Z")

</div>

Example of it working, just not automated with Revise yet:

```julia
❯ julia +1.11 # installed with juliaup

julia> struct A a::Int end

julia> struct A a::Float64 end
ERROR: invalid redefinition of type A
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

```

```julia
❯ julia +beta # installed with juliaup

julia> struct A a::Int end

julia> struct A a::Float64 end

```

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [April 8, 2025, 4:29pm UTC](https://discourse.julialang.org/t/redefining-structure-again-what-the-current-situation-and-what-to-expect/127859/4 "2025-04-08T16:29:47Z")

</div>

Would love if a blogpost can be written about the history of this.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [April 8, 2025, 4:49pm UTC](https://discourse.julialang.org/t/redefining-structure-again-what-the-current-situation-and-what-to-expect/127859/5 "2025-04-08T16:49:53Z")

</div>

The thing I love the most about this is that Julia simultaneously became more dynamic **and** more static. Within a given world age, you no longer need to worry about constants changing behind your back. But then there’s a very well-defined dynamic behavior — invalidation & recompilation — when you do change them. Even better, the printing of objects makes it evident:

```julia-repl
julia> struct A a::Float64 end

julia> const foo = A(2.3)
A(2.3)

julia> struct A a::Int end

julia> foo
@world(A, 40778:40781)(2.3)

julia> const foo = A(4)
A(4)

julia> dump(@world(A, 40781))
struct @world(A, 40778:40781) <: Any
  a::Float64

julia> dump(@world(A, 40782))
struct A <: Any
  a::Int64

julia> foo
A(4)

julia> @world(foo, 40781)
@world(A, 40778:40781)(2.3)

```

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [April 8, 2025, 7:35pm UTC](https://discourse.julialang.org/t/redefining-structure-again-what-the-current-situation-and-what-to-expect/127859/6 "2025-04-08T19:35:12Z")

</div>

Is this in 1.12 _beta1_ ? I can’t see anything related in the [news](https://github.com/JuliaLang/julia/blob/v1.12.0-beta1/NEWS.md)…
