# REPL nested index completion

**URL:** <https://discourse.julialang.org/t/repl-nested-index-completion/104420>\
**Category:** General Usage\
**Tags:** repl\
**Created:** [September 30, 2023, 3:37am UTC](https://discourse.julialang.org/t/repl-nested-index-completion/104420 "2023-09-30T03:37:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkoculak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkoculak/32/28310_2.png) [@mkoculak](https://discourse.julialang.org/u/mkoculak)\
**Post date:** [September 30, 2023, 3:37am UTC](https://discourse.julialang.org/t/repl-nested-index-completion/104420/1 "2023-09-30T03:37:35Z")

</div>

I am working with deeply nested structs, that I would like to navigate like a Dict.  
Got it working thanks to suggestions from [this thread](https://discourse.julialang.org/t/is-it-possible-to-implement-own-tab-autocomplete-for-getindex-in-repl-without-abstractdict/96552), but it only goes one level deep. This is true even if these are plain nested Dicts:

```julia
newDict = Dict(
    "one" => 1,
    "two" => 2,
    "three" => Dict(
        "four" => 4
    )
)

newDict[<TAB> - suggests "one", "two", "three"
newDict["three"][<TAB> - REPL suggests all available symbols
newDict["three"]["<TAB> - REPL suggests all the files in the project folder

```

Is there a trick to making it works correctly?  
Since it suggests some (although wrong) things, maybe there is only some rule to be adjusted?

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [September 30, 2023, 7:13am UTC](https://discourse.julialang.org/t/repl-nested-index-completion/104420/2 "2023-09-30T07:13:44Z")

</div>

> [@mkoculak](#):
>
> Is there a trick to making it works correctly?

I have often wanted this, but I’m not sure it _can_ work. To get tab completion on `newDict["three"][<TAB>]`, you’d have to actually evaluate `newDict["three"]`, no?

Well, I suppose I don’t mean it _can’t_ be done - all things are possible - but executing code with a tab strikes me as a bad idea.

---

<div class="post-metadata">

**Author:** ![mkoculak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkoculak/32/28310_2.png) [@mkoculak](https://discourse.julialang.org/u/mkoculak)\
**Post date:** [September 30, 2023, 12:18pm UTC](https://discourse.julialang.org/t/repl-nested-index-completion/104420/3 "2023-09-30T12:18:34Z")

</div>

True, but I guess it still has to evaluate some code to get the initial keys, so since all of the structure is materialised, it would just require similar steps.

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [October 1, 2023, 4:45am UTC](https://discourse.julialang.org/t/repl-nested-index-completion/104420/4 "2023-10-01T04:45:29Z")

</div>

What I ended up doing to get nestled data was to create as a dict and then convert recursively to a named tuple, these can autocomplete further. That only works if immutability is ok, hence, I sometimes store a ‘Ref’ if I really need mutability.

(Anyway, I’m am currently a bit feeling that I overuse namedtuples a bit, maybe it is bad advice…)

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [October 1, 2023, 9:49am UTC](https://discourse.julialang.org/t/repl-nested-index-completion/104420/5 "2023-10-01T09:49:58Z")

</div>

REPL tab completion is much improved in Julia 1.10.
