Add methods to function from another module

iskyd
Sat, 29 Apr 2023 12:35:06 +0000
General Usage

Hi everyone,

I have a module A that simply define a function

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

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

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?

3 posts - 2 participants