# Repl: should \`ans\` be shared across different prompt modes?

**URL:** https://discourse.julialang.org/t/repl-should-ans-be-shared-across-different-prompt-modes/124694
**Category:** Internals & Design
**Tags:** repl
**Created:** [January 12, 2025, 12:17pm UTC](https://discourse.julialang.org/t/repl-should-ans-be-shared-across-different-prompt-modes/124694 "2025-01-12T12:17:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mfandl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mfandl/32/207120_2.png) [@mfandl](https://discourse.julialang.org/u/mfandl)
#### Post date: [January 12, 2025, 12:17pm UTC](https://discourse.julialang.org/t/repl-should-ans-be-shared-across-different-prompt-modes/124694/1 "2025-01-12T12:17:53Z")

</div>

I just lost some data 🤷 because I didn’t think a command executed in shell mode will overwrite my ans. That is my fault, but anyway, should this be the case?

```julia
julia> 22.5
22.5

julia> ans
22.5

shell> cal
    January 2025      
Su Mo Tu We Th Fr Sa  
          1 2 3 4  
 5 6 7 8 9 10 11  
12 13 14 15 16 17 18  
19 20 21 22 23 24 25  
26 27 28 29 30 31     
                      

julia> ans

julia>

```

The same happens in help mode:

```julia
julia> 22.5
22.5

julia> ans
22.5

help?> ans
search: ans any as abs ones acos tand rand acsc any! tanh axes nand abs2

  ans

  A variable referring to the last computed value, automatically imported to
  the interactive prompt.

julia> ans
  ans

  A variable referring to the last computed value, automatically imported to
  the interactive prompt.

julia>

```

but not in Pkg mode:

```julia
julia> 22.5
22.5

julia> ans
22.5

(@v1.11) pkg> st
Status `~/.julia/environments/v1.11/Project.toml`
  [4c63d2b9] StatsFuns v1.3.2

julia> ans
22.5

julia> 

```

my julia version:

```julia
julia> versioninfo()
Julia Version 1.11.2
Commit 5e9a32e7af2 (2024-12-01 20:02 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

```

---

<div class="post-metadata">

### Author: ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)
#### Post date: [January 13, 2025, 12:07am UTC](https://discourse.julialang.org/t/repl-should-ans-be-shared-across-different-prompt-modes/124694/2 "2025-01-13T00:07:36Z")

</div>

More fun to try: `ans` seems to not work at all (missing identifier) if you’ve [switched to a different module](https://docs.julialang.org/en/v1/stdlib/REPL/#Changing-the-contextual-module-which-is-active-at-the-REPL) for the REPL context.

P.S. an example: First, run `import Serialization`, then type `Serialization` followed by “Alt+M” to switch to this module.

```julia
(Serialization) julia> 1+1
2

(Serialization) julia> ans
ERROR: UndefVarError: `ans` not defined in `Serialization`
Suggestion: check for spelling errors or missing imports.

```
