# Why does the REPL work in Main?

**URL:** <https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 7, 2017, 5:55am UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949 "2017-02-07T05:55:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![fengyang.wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fengyang.wang/32/104_2.png) [@fengyang.wang](https://discourse.julialang.org/u/fengyang.wang)\
**Post date:** [February 7, 2017, 5:55am UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/1 "2017-02-07T05:55:47Z")

</div>

This is really just a question for my curiosity. Why does the Julia REPL work in the Main module, the same module that packages are loaded in, instead of a separate module? Is it because of the convenience of accessing modules that have been loaded from other modules, for, say, debugging purposes?

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [February 7, 2017, 12:09pm UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/2 "2017-02-07T12:09:56Z")

</div>

The real question is why are packages loaded in `Main` instead of somewhere else – since `Main` by definition is “where code is evaluated in a script or the repl”. We initially loaded packages in a module called `Root`, but having `Core`, `Base`, `Main` and `Root` seemed like too many things, so IIRC, I convinced @jeff.bezanson to just load packages in `Main` instead and do away with `Root` altogether. I now think this was a mistake.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 7, 2017, 12:46pm UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/3 "2017-02-07T12:46:58Z")

</div>

I am wondering if the semantics of the language would allow to have a “current” package as a state (similar to, say, Common Lisp), which the user could change, so that whatever happens in the REPL would be evaluated there. This would allow much more interactive development of modules (which has both costs and benefits, to be sure).

One can of course emulate this with `eval(SomeModule, expr)`.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [February 7, 2017, 12:55pm UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/4 "2017-02-07T12:55:40Z")

</div>

Isn’t that what Juno does with ‘working modules’?  
[https://github.com/JunoLab/atom-julia-client/blob/master/manual/workflow.md](https://github.com/JunoLab/atom-julia-client/blob/master/manual/workflow.md)

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 7, 2017, 1:18pm UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/5 "2017-02-07T13:18:28Z")

</div>

Yes. I am also emulating that in Emacs the same way. But having it integrated into the REPL would be nice.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [February 7, 2017, 1:54pm UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/6 "2017-02-07T13:54:40Z")

</div>

Yes, that would certainly be a nice feature.

---

<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:** [February 7, 2017, 2:45pm UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/7 "2017-02-07T14:45:58Z")

</div>

Ref [https://github.com/sglyon/REPLMods.jl](https://github.com/sglyon/REPLMods.jl)

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [February 7, 2017, 9:45pm UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/8 "2017-02-07T21:45:24Z")

</div>

[https://github.com/JuliaLang/julia/issues/17997](https://github.com/JuliaLang/julia/issues/17997)

---

<div class="post-metadata">

**Author:** ![sglyon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sglyon/32/67_2.png) [@sglyon](https://discourse.julialang.org/u/sglyon)\
**Post date:** [February 7, 2017, 9:46pm UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/9 "2017-02-07T21:46:57Z")

</div>

Thanks for the ref @kristoffer.carlsson

@StefanKarpinski is there still interest in getting that into base? I could try to find time to hack that in if so

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 8, 2017, 8:13am UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/10 "2017-02-08T08:13:38Z")

</div>

That would be great.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [February 8, 2017, 5:12pm UTC](https://discourse.julialang.org/t/why-does-the-repl-work-in-main/1949/11 "2017-02-08T17:12:05Z")

</div>

Yes, I think that would be great to have in Base. Probably want to have an API discussion first though.
