# Add methods to function from another module

**URL:** <https://discourse.julialang.org/t/add-methods-to-function-from-another-module/98083>\
**Category:** General Usage\
**Tags:** modules\
**Created:** [April 29, 2023, 12:35pm UTC](https://discourse.julialang.org/t/add-methods-to-function-from-another-module/98083 "2023-04-29T12:35:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iskyd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iskyd/32/44797_2.png) [@iskyd](https://discourse.julialang.org/u/iskyd)\
**Post date:** [April 29, 2023, 12:35pm UTC](https://discourse.julialang.org/t/add-methods-to-function-from-another-module/98083/1 "2023-04-29T12:35:06Z")

</div>

Hi everyone,

I have a module A that simply define a function

```julia
module A

"""
    f(config::ConnectionConfiguration)
    Connects to the database using the given configuration.
"""
function connect end
end

```

Now from module B I’m trying to add new methods to that function doing something like that

```julia
module B
using A

A.connect(config::SQLiteConnectionConfiguration) = SQLite.DB(config.dbname)
end

```

At these point everything works fine but I got a warning message from vscode extension in module B saying

> `A.connect` is a `Function` . **0** methods for function `A.connect`

Then I need to use these two modules in my application so I do

```julia
using A
using B

A.connect(config)

```

Here I got another warning message from vscode extension saying the same thing

> `A.connect` is a `Function` . **0** methods for function `A.connect`

Both A and B are packages.  
Note that everything is working fine. The main problem seems to be the vscode extension the is not able to find the methods implementation and having a lot of warning and not be able to use autocomplete is not good.  
In my application I don’t want to use B.connect since I could have also C, D and so on that implements new methods and i want to use the dispatch.

How can I solve those issues? Is this the right thing to do?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [April 29, 2023, 5:53pm UTC](https://discourse.julialang.org/t/add-methods-to-function-from-another-module/98083/2 "2023-04-29T17:53:06Z")

</div>

> [@iskyd](#):
>
> `using A`

you need `import A` instead

---

<div class="post-metadata">

**Author:** ![iskyd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iskyd/32/44797_2.png) [@iskyd](https://discourse.julialang.org/u/iskyd)\
**Post date:** [April 30, 2023, 9:53am UTC](https://discourse.julialang.org/t/add-methods-to-function-from-another-module/98083/3 "2023-04-30T09:53:01Z")

</div>

Hi @jling thanks for pointing it out. I tried using import instead. I still has warnings in module B (that extends functions in module A) but I don’t have anymore warnings in the applications that uses it.

I’m doing something like

```julia
module A

"""
    mapping(db::Type{S}, t::Type{T})::String where {S,T}
    Returns the mapping for the given database and type
"""
function mapping end

end

```

Then in module B

```julia
module B

import A
using SQLite

A.mapping(db::Type{SQLite.DB}, t::Type{Int64})::String = "INTEGER"

end

```

vscode returns “Possible method call error”.

Also I wanted to ask what is the real difference here between import and using because from documentation [Modules · The Julia Language](https://docs.julialang.org/en/v1/manual/modules/#using-and-import-with-specific-identifiers,-and-adding-methods) you can use both using and import to add methods using module path.
