Extend package methods / write add-ons

Hi, I am trying to write an add-on for a package, but I am struggling with a – likely minor – issue.

Suppose that some package has a function

function foo(S1::Any)
    ....
    bar(S1)
    ....

and bar(S1) is defined within the package to accept only a limited number of datatypes. I am trying to extend bar in a separate Julia script (not included in the package) to accept more datatypes. I tried to implement it via

bar(S1::SomeOtherDatatype) = do something

but I am getting an error when using it in tandem with the package, because the latter is only looking at its own internal functions. What is the best way for implementing something like that?

You probably should do:

PackageToBeExtended.bar(S1::SomeOtherDatatype) = do something

4 Likes