# Trouble exporting functions from different packages with different methods but same name

**URL:** <https://discourse.julialang.org/t/trouble-exporting-functions-from-different-packages-with-different-methods-but-same-name/88972>\
**Category:** General Usage\
**Created:** [October 19, 2022, 4:24pm UTC](https://discourse.julialang.org/t/trouble-exporting-functions-from-different-packages-with-different-methods-but-same-name/88972 "2022-10-19T16:24:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [October 19, 2022, 4:24pm UTC](https://discourse.julialang.org/t/trouble-exporting-functions-from-different-packages-with-different-methods-but-same-name/88972/1 "2022-10-19T16:24:58Z")

</div>

Hi!

I have two different packages. Both export the same function `getLandSea`, but the methods are different. These two packages sometimes intersect, because they are climate-related datasets, but are for different datasets so they should be separate packages.

However, I am unable to export these functions. Instead, I must use `ERA5Reanalysis.getLandSea` or `NASAPrecipitation.getLandSea` to use these functions. Is there are way to get around this?

Best  
Nat

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [October 19, 2022, 8:52pm UTC](https://discourse.julialang.org/t/trouble-exporting-functions-from-different-packages-with-different-methods-but-same-name/88972/2 "2022-10-19T20:52:51Z")

</div>

One option is `import ... as`:

```julia
julia> module A
         f() = "A"
         export f
       end
Main.A

julia> module B
         f() = "A"
         export f
       end
Main.B

julia> using ..A, ..B

julia> import ..A.f as fA

julia> import ..B.f as fB

julia> fA()
"A"

```

---

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [October 20, 2022, 6:00am UTC](https://discourse.julialang.org/t/trouble-exporting-functions-from-different-packages-with-different-methods-but-same-name/88972/3 "2022-10-20T06:00:24Z")

</div>

As I understand it, one common way to solve this is to have a `...Base` package (something like `ClimateDatasetBase.jl`) where you declare

```julia
function getLandSea end

```

and then have

```julia
import ClimateDatasetBase: getLandSea
function getLandSea(...)
 ...
end

```

in both your packages, to make them actually be methods of the same function.

Whether this is worth doing of course depends on how many such functions you have, but such a base package also (1) lets you define more of a common interface between the packages, (2) is a place to define `Abstract...` types for the child packages to subtype, and (3) can make it easier for others writing a climate dataset-handling package to integrate better with your existing ones.
