# How to handle conflicting functions between 2 packages

**URL:** <https://discourse.julialang.org/t/how-to-handle-conflicting-functions-between-2-packages/105219>\
**Category:** Modelling & Simulations\
**Tags:** dynamical-systems\
**Created:** [October 20, 2023, 7:37am UTC](https://discourse.julialang.org/t/how-to-handle-conflicting-functions-between-2-packages/105219 "2023-10-20T07:37:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hisacro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hisacro/32/202631_2.png) [@hisacro](https://discourse.julialang.org/u/hisacro)\
**Post date:** [October 20, 2023, 7:37am UTC](https://discourse.julialang.org/t/how-to-handle-conflicting-functions-between-2-packages/105219/1 "2023-10-20T07:37:57Z")

</div>

The issue is popping very often with DynamicalSystems.ji package now, here’s a sample

of using …

```julia
julia> IntervalBox(-2..2, -2..2)
WARNING: both ChaosTools and GLMakie export ".."; uses of it in module Main must be qualified
ERROR: UndefVarError: `..` not defined
Stacktrace:
 [1] top-level scope
   @ REPL[614]:1

```

there was another function name too poincaresos,

```julia
help?> poincaresos
search: poincaresos brainscan_poincaresos interactive_poincaresos interactive_poincaresos_scan poincaremap PoincareMap poincare_map

  poincaresos(A::AbstractStateSpaceSet, plane; kwargs...) → P::StateSpaceSet

  Calculate the Poincaré surface of section of the given dataset with the given plane by performing linear interpolation betweeen points that sandwich the
  hyperplane.

  Argument plane and keywords direction, warning, save_idxs are the same as in PoincareMap.

  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  poincaresos(ds::CoupledODEs, plane, T = 1000.0; kwargs...) → P::StateSpaceSet

  Return the iterations of ds on the Poincaré surface of section with the plane, by evolving ds up to a total of T. Return a StateSpaceSet of the points that are
  on the surface of section.

  This function initializes a PoincareMap and steps it until its current_crossing_time exceeds T. You can also use trajectory with PoincareMap to get a sequence
  of N::Int points instead.

  The keywords Ttr, save_idxs act as in trajectory. See PoincareMap for plane and all other keywords.

```

now if I want to use the second function how will i proceed? second one is from chaostools.poincaresos even if I explicitly give that, it’s not working. How to over come these

---

<div class="post-metadata">

**Author:** ![algunion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/algunion/32/51630_2.png) [@algunion](https://discourse.julialang.org/u/algunion)\
**Post date:** [October 20, 2023, 9:52am UTC](https://discourse.julialang.org/t/how-to-handle-conflicting-functions-between-2-packages/105219/2 "2023-10-20T09:52:02Z")

</div>

@hisacro, welcome to Julia Discourse.

I don’t think the `..` is connected to the `poincaresos` method calling at all. So let me separate them as follows:

### `..` case

This is a tricky one because of the `infix` nature of the function.

I think the only straightforward solution might be to use `import` for the package from which you don’t use the `..` function and `using` for the other one.

In your case, the qualified usage means something like `IntervalBox.:(..)(-2, 2)`, which is messing greatly with the ergonimics. So, I’d stick with only performing `using` on one of the packages and use `import` for the other.

Keep in mind that if you want to avoid the qualified access for various functions in the package you only imported by `import`, you can always do: `using Package: f1, f2`.

I hope the following example helps:

```julia
import GLMakie
using GLMakie: Figure, Axis, scatter!
using ChaosTools

```

In the above scenario you’ll be able to properly use your `..` function (as infix) and also easily use functions from `GLMakie` (you can extend the list as needed). There is no longer a conflict related to `..` function (in this scenario we are opting for using the `..` from the `ChaosTools` package).

I hope this makes sense.

### `poincaresos` function

Here you do not have two `poincaresos` functions. You only have more than one _method_ for this function.

You actually do not need to do anything else than call the function with the appropriate arguments. Julia will figure out which method to use based on the arguments you use.

```julia
myf(a::Int, b::Int) = a + b
myf(a::Float64, b::Float64) = a - b

myf(20, 10)
# will return 30

my(20.0, 10.0)
# will return 10.0

```

You can go into more depth about the methods [here](https://docs.julialang.org/en/v1/manual/methods/).

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [October 20, 2023, 10:28am UTC](https://discourse.julialang.org/t/how-to-handle-conflicting-functions-between-2-packages/105219/3 "2023-10-20T10:28:50Z")

</div>

> [@algunion](#):
>
> This is a tricky one because of the `infix` nature of the function.
> 
> I think the only straightforward solution might be to use `import` for the package from which you don’t use the `..` function and `using` for the other one.
> 
> In your case, the qualified usage means something like `IntervalBox.:(..)(-2, 2)`, which is messing greatly with the ergonimics. So, I’d stick with only performing `using` on one of the packages and use `import` for the other.

For the package that you import with `import`, instead of with `using`, you can assign its `..` operator to a constant. If you pick one of the supported names, it can still be an infix operator. Something like this:

```julia
import A

# This is a Unicode symbol, it's not just three periods.
const … = A.:(..)

```

A REPL example with other operators:

```julia-repl
julia> const ⊕ = +
+ (generic function with 189 methods)

julia> 3 ⊕ 2
5

```

Regrettably, one has to look at the source to see what are all the supported operators, e.g.:

> <https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm#L1-L21>

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [October 20, 2023, 11:38am UTC](https://discourse.julialang.org/t/how-to-handle-conflicting-functions-between-2-packages/105219/4 "2023-10-20T11:38:07Z")

</div>

yeah, sorry about that… It’s because the devs of Interval Arithemetic Root finding and the devs of Makie using different package definition for the interval type. I asked a couple of times that this should change, as there is no real reason for two packages to define Interval type, but it hasn’t happened yet. So until it happens we are stuck with this problem…

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [October 20, 2023, 1:32pm UTC](https://discourse.julialang.org/t/how-to-handle-conflicting-functions-between-2-packages/105219/5 "2023-10-20T13:32:24Z")

</div>

> [@nsajko](#):
>
> Regrettably, one has to look at the source to see what are all the supported operators

News from the (1.10) future: it’s possible to see these without having to visit github and browse through reams of femtolisp:

```julia-term
julia-1.10> join(filter(s -> length(s) ==1, 
    Base.JuliaSyntax._kind_names))

```

which will show you many hundreds of strange glyphs, many of which you _could_ use as operators.

Such as `⅋`:

```julia-term
help?> ⅋
"⅋" can be typed by \upand<tab>

```

Checking it out:

```julia-term
julia-1.10> Base.operator_precedence(:⅋)
12

julia-1.10> Base.isbinaryoperator(:⅋)
true

julia-1.10> Base.isoperator(:⅋)
true

julia-1.10> ⅋(x, y) = print("let's upand $x $y")
⅋ (generic function with 1 method)

julia-1.10> ⅋(2, 3)
let's upand 2 3

```
