# Reset Main without restarting the REPL

**URL:** <https://discourse.julialang.org/t/reset-main-without-restarting-the-repl/48393>\
**Category:** General Usage\
**Created:** [October 14, 2020, 9:28pm UTC](https://discourse.julialang.org/t/reset-main-without-restarting-the-repl/48393 "2020-10-14T21:28:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ginter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ginter/32/9829_2.png) [@Ginter](https://discourse.julialang.org/u/Ginter)\
**Post date:** [October 14, 2020, 9:28pm UTC](https://discourse.julialang.org/t/reset-main-without-restarting-the-repl/48393/1 "2020-10-14T21:28:48Z")

</div>

I understand that we can’t delete existing bindings or redefine structs without replacing the entire module. Is there a way of reinitializing the `Main` module without having to close the REPL?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 14, 2020, 9:34pm UTC](https://discourse.julialang.org/t/reset-main-without-restarting-the-repl/48393/2 "2020-10-14T21:34:41Z")

</div>

is there some particular use case that Revise.jl doesn’t cover?

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [October 15, 2020, 12:27am UTC](https://discourse.julialang.org/t/reset-main-without-restarting-the-repl/48393/3 "2020-10-15T00:27:56Z")

</div>

Sorry, I do not understand what you mean by _reinitializing the `Main` module_, what exactly this would consist of?

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [October 15, 2020, 3:21pm UTC](https://discourse.julialang.org/t/reset-main-without-restarting-the-repl/48393/4 "2020-10-15T15:21:41Z")

</div>

Revise doesn’t allow redefining structs in `Main`, unlike in modules. I guess that might be an inconvenience?

```julia
julia> using Revise

julia> struct abc end

julia> struct abc{T}
       x :: T
       end
ERROR: invalid redefinition of constant abc

julia> module temp
       struct abc end
       end
Main.temp

julia> module temp
       struct abc{T}
       x :: T
       end
       end
WARNING: replacing module temp.
Main.temp

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 15, 2020, 3:26pm UTC](https://discourse.julialang.org/t/reset-main-without-restarting-the-repl/48393/5 "2020-10-15T15:26:02Z")

</div>

[https://github.com/JuliaLang/julia/pull/33872](https://github.com/JuliaLang/julia/pull/33872) makes this pretty easy to implement ([https://github.com/JuliaLang/julia/pull/33872#issuecomment-703260632](https://github.com/JuliaLang/julia/pull/33872#issuecomment-703260632)).

---

<div class="post-metadata">

**Author:** ![Ginter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ginter/32/9829_2.png) [@Ginter](https://discourse.julialang.org/u/Ginter)\
**Post date:** [October 15, 2020, 4:42pm UTC](https://discourse.julialang.org/t/reset-main-without-restarting-the-repl/48393/6 "2020-10-15T16:42:38Z")

</div>

Yes, I’m mostly looking for an easy way to edit structs when working in projects.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [October 15, 2020, 4:44pm UTC](https://discourse.julialang.org/t/reset-main-without-restarting-the-repl/48393/7 "2020-10-15T16:44:27Z")

</div>

If you haven’t decided on how your struct should look, consider using a [NamedTuple](https://docs.julialang.org/en/v1/base/base/#Core.NamedTuple) until the layout is finalized and then switch to a struct. They work with Revise and you can explore to your hearts content.

---

<div class="post-metadata">

**Author:** ![Ginter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ginter/32/9829_2.png) [@Ginter](https://discourse.julialang.org/u/Ginter)\
**Post date:** [October 15, 2020, 5:46pm UTC](https://discourse.julialang.org/t/reset-main-without-restarting-the-repl/48393/8 "2020-10-15T17:46:33Z")

</div>

Removing all user-defined variables
