# Using Cassette to overdub just some methods

**URL:** https://discourse.julialang.org/t/using-cassette-to-overdub-just-some-methods/38139
**Category:** General Usage
**Tags:** question
**Created:** [April 24, 2020, 11:27am UTC](https://discourse.julialang.org/t/using-cassette-to-overdub-just-some-methods/38139 "2020-04-24T11:27:10Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![lino98](https://avatars.discourse-cdn.com/v4/letter/l/e8c25b/32.png) [@lino98](https://discourse.julialang.org/u/lino98)
#### Post date: [April 24, 2020, 11:27am UTC](https://discourse.julialang.org/t/using-cassette-to-overdub-just-some-methods/38139/1 "2020-04-24T11:27:10Z")

</div>

I’m working on developing a software that mesure performance of a julia program and i’m using cassette since i have to intercept function calls and modify them, the problem is that when i overdub a function it recursively overdub also the function that are native of the julia language but i just want to apply this on functions declared by the user. is this possible?

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [April 24, 2020, 2:29pm UTC](https://discourse.julialang.org/t/using-cassette-to-overdub-just-some-methods/38139/2 "2020-04-24T14:29:10Z")

</div>

Please provide more information about what you are doing.

You can restrict the overdub to only working on certain _types_.  
So you can define a custom type and restrict the overdub to that.

---

<div class="post-metadata">

### Author: ![lino98](https://avatars.discourse-cdn.com/v4/letter/l/e8c25b/32.png) [@lino98](https://discourse.julialang.org/u/lino98)
#### Post date: [April 24, 2020, 4:57pm UTC](https://discourse.julialang.org/t/using-cassette-to-overdub-just-some-methods/38139/3 "2020-04-24T16:57:08Z")

</div>

for example in simple code like

```julia
function a()
    for x = 0:2000000000 end
end

function b()
    for y = 0:1900000000 end
end

function test(arg)
    arg = 1 + 1
end

function main()
    a()
    b()
    test(0)
    println("Done!")
end

```

i want cassette to overdub the functions a, b and test but not the call to the increment in the for loop.

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [April 24, 2020, 6:09pm UTC](https://discourse.julialang.org/t/using-cassette-to-overdub-just-some-methods/38139/4 "2020-04-24T18:09:56Z")

</div>

Then you can make your own type and define + on that type, then overdub + only for that type.

---

<div class="post-metadata">

### Author: ![lino98](https://avatars.discourse-cdn.com/v4/letter/l/e8c25b/32.png) [@lino98](https://discourse.julialang.org/u/lino98)
#### Post date: [April 27, 2020, 8:56am UTC](https://discourse.julialang.org/t/using-cassette-to-overdub-just-some-methods/38139/5 "2020-04-27T08:56:56Z")

</div>

Maybe i didn’t explain my self properly, my goal is to create a package that iterates over all user defined functions in a julia source code (that i didn’t edit) and apply some behaviour to all those functions. My problem is that overdub is recursive and overdubs also the language defined function like add ecc… sorry for the misunderstanding

---

<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: [April 27, 2020, 9:21am UTC](https://discourse.julialang.org/t/using-cassette-to-overdub-just-some-methods/38139/6 "2020-04-27T09:21:04Z")

</div>

I am not very familiar with Cassette but isn’t the whole point that you overdub everything recursively so that you thread your “context” through the whole computation and can “inject” your specific hooks where you want. Where you don’t want to do anything special you just have a “no-op” overdub.

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [April 27, 2020, 3:29pm UTC](https://discourse.julialang.org/t/using-cassette-to-overdub-just-some-methods/38139/7 "2020-04-27T15:29:52Z")

</div>

You will need to post the code that you used. Using `::typeof(a)` in the overdub you can overdub any function called `a`. Using type annotations on the arguments of the function you can control which methods you overdub.
