# What are the limitations of completion in the REPL?

**URL:** https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944
**Category:** General Usage
**Tags:** repl
**Created:** [April 3, 2022, 1:54pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944 "2022-04-03T13:54:14Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [April 3, 2022, 1:54pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/1 "2022-04-03T13:54:14Z")

</div>

The manual states “Tab completion can also help completing fields:”, using the example of UUIDs.  
However, I recently found that some symbols are not completed ([Where is sparse ldlt? - #2 by skleinbo](https://discourse.julialang.org/t/where-is-sparse-ldlt/78929/2)).

So, does anyone know what are the limitations and how does the completion work (or does not?)?

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [April 3, 2022, 2:34pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/2 "2022-04-03T14:34:00Z")

</div>

REPL completion works by looking up what symbols are associated with the object in front of the dot. If a symbol is not part of those associated symbols, completion can’t know about it on its own. In your example, SuiteSparse is extending a function from another module, in this case LinearAlgebra, which means the `ldlt` symbol is not associated with the module `SuiteSparse` in the first place, resulting in there not being completion for it.

It’s also not trivial to just make that available anyway, since `ldlt` doesn’t exist from the POV of the `SuiteSparse` module in the first place. Writing `SuiteSparse.ldlt` would have to reference `LinearAlgebra.ldlt`, which seems very confusing to me.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [April 3, 2022, 3:45pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/3 "2022-04-03T15:45:28Z")

</div>

So are you saying that the completion can only look up functions, not methods?

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [April 3, 2022, 10:12pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/4 "2022-04-03T22:12:39Z")

</div>

No, not exactly. Both the function and the method live in `LinearAlgebra`, the text resulting in the method is just “physically” written in `SuiteSparse`. REPL completion can look up things that actually end up as part of `SuiteSparse`, which the method defined for `ldlt` doesn’t.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [April 3, 2022, 10:27pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/5 "2022-04-03T22:27:19Z")

</div>

How did you come to that conclusion? I can see `ldlt` in [https://github.com/JuliaSparse/SuiteSparse.jl/blob/f31dc2e45c9edd2f9969c336a440c9aca13d6e44/src/cholmod.jl#L1336](https://github.com/JuliaSparse/SuiteSparse.jl/blob/f31dc2e45c9edd2f9969c336a440c9aca13d6e44/src/cholmod.jl#L1336)

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [April 3, 2022, 10:40pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/6 "2022-04-03T22:40:32Z")

</div>

> [@PetrKryslUCSD](#):
>
> How did you come to that conclusion?

It’s imported here:

> <https://github.com/JuliaSparse/SuiteSparse.jl/blob/f31dc2e45c9edd2f9969c336a440c9aca13d6e44/src/cholmod.jl#L20>

which means that the `ldlt` you link extends that function with a new method instead of creating an entirely different function.

You can also run `SuiteSparse.ldlt === LinearAlgebra.ldlt` to check that they’re the same.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [April 3, 2022, 10:42pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/7 "2022-04-03T22:42:24Z")

</div>

Right, but still, the method is defined in CHOLMOD. Is that not visible to the completion mechanism?

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [April 3, 2022, 10:47pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/8 "2022-04-03T22:47:19Z")

</div>

No, REPL completion doesn’t know (or care) where things are written in a file, only whether they’re part of the resulting module or not. Files in general are not nearly as important in julia as in other languages like python - they’re not coupled to the module structure or what’s reachable from them in code per se.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [April 3, 2022, 10:59pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/9 "2022-04-03T22:59:51Z")

</div>

I understand that (I think), but the method is defined in a module. Shouldn’t it be visible in the module then?

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [April 4, 2022, 3:07am UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/10 "2022-04-04T03:07:27Z")

</div>

Okay, here is an example:

```julia
julia> include("m1.jl")                                                                                                                                               
Main.m1                                                                                                                                                               
                                                                                                                                                                      
julia> include("m2.jl")                                                                                                                                               
Main.m2                                                                                                                                                               
                                                                                                                                                                      
julia> Main.m2.                                                                                                                                                       
                                                                                                                                                                      
eval f include                                                                                                                                              
julia> Main.m2.f                                                                                                                                                      
f (generic function with 2 methods)                                                                                                                                   
                                                                                                                                                                      
julia> Main.m1.                                                                                                                                                       
                                                                                                                                                                      
eval f include                                                                                                                                              
julia> Main.m1.f                                                                                                                                                      
f (generic function with 2 methods)                                                                                                                                   
                                                                                                                                                                      
shell> cat m1.jl m2.jl                                                                                                                                                
module m1                                                                                                                                                             
                                                                                                                                                                      
export f                                                                                                                                                              
                                                                                                                                                                      
function f(x::Float64)                                                                                                                                                
    x*4                                                                                                                                                               
end                                                                                                                                                                   
                                                                                                                                                                      
end                                                                                                                                                                   
module m2                                                                                                                                                             
                                                                                                                                                                      
import ..m1: f                                                                                                                                                        
                                                                                                                                                                      
export f                                                                                                                                                              
                                                                                                                                                                      
function f(x::Int64)                                                                                                                                                  
    f(Float64(x))                                                                                                                                                     
end                                                                                                                                                                   
                                                                                                                                                                      
end                                                                                                                                                                   

```

As you can see, completion suggests function methods for `f` from both module `m1` and module `m2`, even though `m2` only defines a method for `f`. Isn’t that the same situation as for `ldlt`?

Edit: With a submodule.

```julia
julia> include("m3.jl")                                                                                                                                               
WARNING: replacing module m3.                                                                                                                                         
Main.m3                                                                                                                                                               
                                                                                                                                                                      
julia> Main.m3.                                                                                                                                                       
eval include subm3                                                                                                                                                
julia> Main.m3.subm3.                                                                                                                                                 
eval f include                                                                                                                                              
julia> Main.m3.subm3.f                                                                                                                                                
f (generic function with 2 methods)                                                                                                                                   
                                                                                                                                                                      
shell> cat m3.jl                                                                                                                                                      
module m3                                                                                                                                                             
                                                                                                                                                                      
module subm3                                                                                                                                                          
import ...m1: f                                                                                                                                                       
                                                                                                                                                                      
export f                                                                                                                                                              
                                                                                                                                                                      
function f(x::Int64)                                                                                                                                                  
    f(Float64(x))                                                                                                                                                     
end                                                                                                                                                                   
                                                                                                                                                                      
end                                                                                                                                                                   
                                                                                                                                                                      
end                                                                                                                                                                   
                                                                                                                                                                      

```

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [April 4, 2022, 6:10am UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/11 "2022-04-04T06:10:57Z")

</div>

> [@PetrKryslUCSD](#):
>
> Shouldn’t it be visible in the module then?

This is where the distinction between “where it’s written” and “where it’s associated with/where the method belongs” lies. It’s _written_ in that file, yes, but that doesn’t necessarily mean that it semantically belongs to that module. It’s similar to when you do

```julia
module B
   # empty module
end

# Here B.C doesn't work

module A
    using ..B

    @eval B const C = 1
end

# After this, B.C works

```

You wouldn’t expect `A.C` to work, right? The same goes for `ldlt` of `SuiteSparse`.

> [@PetrKryslUCSD](#):
>
> As you can see, completion suggests function methods for `f` from both module `m1` and module `m2` , even though `m2` only defines a method for `f` . Isn’t that the same situation as for `ldlt` ?

No, because in you’re example you’re reexporting `f` from `m2`, which associates the name with `m2` as well (and `m1` of course already has `f` associated with it). This is not the case for `SuiteSparse` - the method is not reexported (the reason for which is possibly due to the method [only being added conditionally](https://github.com/JuliaSparse/SuiteSparse.jl/blob/f31dc2e45c9edd2f9969c336a440c9aca13d6e44/src/SuiteSparse.jl#L27-L31)).

The same goes for your `submodule` example. The submodule `subm3` reexports `f` (which happens independently of being placed in `m3`) and thus has the name available, while `m3` itself does not. It doesn’t know about any `f` (function or methods) at all - it only knows about the name `subm3`.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [April 4, 2022, 1:31pm UTC](https://discourse.julialang.org/t/what-are-the-limitations-of-completion-in-the-repl/78944/12 "2022-04-04T13:31:31Z")

</div>

Of course, the `export` is the key. You are right.
