# Overwriting Functions from another package in your package

**URL:** <https://discourse.julialang.org/t/overwriting-functions-from-another-package-in-your-package/83545>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 30, 2022, 3:53am UTC](https://discourse.julialang.org/t/overwriting-functions-from-another-package-in-your-package/83545 "2022-06-30T03:53:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![arbitrandomuser](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/arbitrandomuser/32/19374_2.png) [@arbitrandomuser](https://discourse.julialang.org/u/arbitrandomuser)\
**Post date:** [June 30, 2022, 3:53am UTC](https://discourse.julialang.org/t/overwriting-functions-from-another-package-in-your-package/83545/1 "2022-06-30T03:53:54Z")

</div>

I’m implementing a feature for `Javis` . `Javis` is an animation library . To draw every frame it uses  
`Luxor` . Now for this feature to be implemented I need to change the behaviour of a few functions  
in `Javis`. I am overwriting them in `Javis` .

But I get warnings when `using Javis` that the functions are overwritten and incremental compilation  
may be broken .

For example a function in particular is  
`Luxor.strokepath()`

which does

```julia
function strokepath()
    <call some cairo functions >
end

```

what I do in Javis is

```julia
function Luxor.strokepath()
        <some code using Javis.global_var and Javis functions>
         <call some cairo functions>
end

```

So two questions .

1. This amounts to type piracy , is there a way to implement something like this without type piracy altogether.  
2)When `using Javis` I get warnings about the luxor functions being overwritten in `Javis` and `incremental compilation may be fatally broken for this module` . How bad is this ?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [June 30, 2022, 9:25am UTC](https://discourse.julialang.org/t/overwriting-functions-from-another-package-in-your-package/83545/2 "2022-06-30T09:25:24Z")

</div>

Why can’t you just have a `Javis.strokepath` that does:

```julia
function strokepath()
    <some code using Javis.global_var and Javis functions>
    Luxor.strokepath()
end

```

?

---

<div class="post-metadata">

**Author:** ![arbitrandomuser](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/arbitrandomuser/32/19374_2.png) [@arbitrandomuser](https://discourse.julialang.org/u/arbitrandomuser)\
**Post date:** [June 30, 2022, 9:42am UTC](https://discourse.julialang.org/t/overwriting-functions-from-another-package-in-your-package/83545/3 "2022-06-30T09:42:56Z")

</div>

there are many functions from `Luxor` that are exported by `Javis`.

Take `line` for example which is used to draw a line .

`line( O , O +(100,100) , :stroke )` would be one example of how a Javis user would draw a line  
this `line` is defined in Luxor which eventually calls `strokepath()` to lay down the line on the canvas.  
There are many such functions in Luxor to draw various things.

What I want to do is change the behavior of that strokepath() which gets eventually called inside all these drawing functions that Luxor provides.

To give you a little more perspective (if it helps , else ignore this) , my initial attempt was to use `Cassette.jl` to intercept the calls and replace with my own code, but me (and some of the devs ) think its too hacky and we dont want to have Cassette.jl as a dep just for this feature.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [June 30, 2022, 10:06am UTC](https://discourse.julialang.org/t/overwriting-functions-from-another-package-in-your-package/83545/4 "2022-06-30T10:06:37Z")

</div>

There is no way to directly monkey patch functions like this in a good way if the function itself does not provide the flexibility to do so in the first place. One possibility is to suggest some API in Luxor to be able to have enough flexibility to add the extra stuff you need.
