# Is it possible to have the same module imported twice with slightly different behaviour?

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-have-the-same-module-imported-twice-with-slightly-different-behaviour/96344>\
**Category:** General Usage\
**Created:** [March 20, 2023, 2:37pm UTC](https://discourse.julialang.org/t/is-it-possible-to-have-the-same-module-imported-twice-with-slightly-different-behaviour/96344 "2023-03-20T14:37:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jt1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jt1/32/38331_2.png) [@jt1](https://discourse.julialang.org/u/jt1)\
**Post date:** [March 20, 2023, 2:37pm UTC](https://discourse.julialang.org/t/is-it-possible-to-have-the-same-module-imported-twice-with-slightly-different-behaviour/96344/1 "2023-03-20T14:37:23Z")

</div>

Say I want to overwrite the behaviour of a Module (eg. the `rank` function in `LinearAlgebra` always returns 0 (this is a fictional problem)), but I don’t want to brake other modules that use `LinearAlgebra` (eg. I want `rank` when called in `DifferentialEquations` to still work correctly). Is this possible?

```julia
using LinearAlgebra
const LinearAlgebra2 = deepcopy(LinearAlgebra) #doesn't work
LinearAlgera2.rank(::Matrix) = 0

```

Note: defining another function `my_rank` is not possible, because then the internal functions in `LinearAlgebra2` like `inv` would still use `rank` instead of `my_rank`.

AFAIK, this is only possible by making a new Module LinearAlgebra2 and reusing all the code except `rank`.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [March 20, 2023, 2:41pm UTC](https://discourse.julialang.org/t/is-it-possible-to-have-the-same-module-imported-twice-with-slightly-different-behaviour/96344/2 "2023-03-20T14:41:57Z")

</div>

The general solution here is to make your own type `<: AbstractArray` which has the behavior you want.
