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, but it only goes one level deep. This is true even if these are plain nested Dicts:
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?
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.
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.
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…)