# How to replace current module from itself?

**URL:** <https://discourse.julialang.org/t/how-to-replace-current-module-from-itself/97282>\
**Category:** General Usage\
**Created:** [April 9, 2023, 4:50pm UTC](https://discourse.julialang.org/t/how-to-replace-current-module-from-itself/97282 "2023-04-09T16:50:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [April 9, 2023, 4:50pm UTC](https://discourse.julialang.org/t/how-to-replace-current-module-from-itself/97282/1 "2023-04-09T16:50:04Z")

</div>

Hello, how to replace current module from itself? It is possible? Need use module REPL or enough macro?

---

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [April 9, 2023, 5:23pm UTC](https://discourse.julialang.org/t/how-to-replace-current-module-from-itself/97282/2 "2023-04-09T17:23:31Z")

</div>

```julia
julia> module RootModule

           function create_or_replace_slave_module()
               @eval(RootModule, module SlaveModule
                                   import ..RootModule
                                   replace_this_module() = RootModule.create_or_replace_slave_module()
                                   end)
               return nothing
           end
       end
Main.RootModule

julia> RootModule.create_or_replace_slave_module()

julia> RootModule.SlaveModule.replace_this_module()
WARNING: replacing module SlaveModule.

julia>

```
