# Is there a way to suppress "method overwritten" warnings?

**URL:** https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233
**Category:** New to Julia
**Created:** [April 15, 2017, 1:21pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233 "2017-04-15T13:21:21Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![DIzer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dizer/32/3971_2.png) [@DIzer](https://discourse.julialang.org/u/DIzer)
#### Post date: [April 15, 2017, 1:21pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/1 "2017-04-15T13:21:21Z")

</div>

more over i am still not sure whether it is bug or ugly implemented feature…

---

<div class="post-metadata">

### Author: ![DIzer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dizer/32/3971_2.png) [@DIzer](https://discourse.julialang.org/u/DIzer)
#### Post date: [April 15, 2017, 1:30pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/2 "2017-04-15T13:30:35Z")

</div>

to the corrector! It was not the good idea to cut off words from the original topic definition. For the words “confusing” and “useless” describe the problem more precisely/

---

<div class="post-metadata">

### Author: ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)
#### Post date: [April 15, 2017, 1:39pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/3 "2017-04-15T13:39:02Z")

</div>

Overwriting method definitions can lead to unexpected behaviors due to issue [#265](https://github.com/julialang/julia/issues/265#issuecomment-2922783)

This issue has been solved in a still unreleased version of Julia (Julia 0.6). So that now on 0.6

```julia
julia> f(x) = 1
f (generic function with 1 method)

julia> f(x) = 2
f (generic function with 1 method)

```

doesn’t warn anymore.

However, if you are redefining methods of a function so often that the warnings become annoying, you may consider using [anonymous functions](https://docs.julialang.org/en/stable/manual/functions/#anonymous-functions). They should also behave better wrt possible issues deriving from issue #265.

---

<div class="post-metadata">

### Author: ![DIzer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dizer/32/3971_2.png) [@DIzer](https://discourse.julialang.org/u/DIzer)
#### Post date: [April 15, 2017, 1:41pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/4 "2017-04-15T13:41:15Z")

</div>

Thank you. BTW Do you know when it will be released?

---

<div class="post-metadata">

### Author: ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)
#### Post date: [April 15, 2017, 1:45pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/5 "2017-04-15T13:45:42Z")

</div>

Reasonably soon I guess. It’s discussed in [this topic](https://discourse.julialang.org/t/0-6-release-timeline/836/41). If you want to play with it a bit, you can download the nightly builds on the julialang homepage. I think it already works fine but some of the packages may not be ready for the new version.

---

<div class="post-metadata">

### Author: ![DIzer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dizer/32/3971_2.png) [@DIzer](https://discourse.julialang.org/u/DIzer)
#### Post date: [April 15, 2017, 1:48pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/6 "2017-04-15T13:48:26Z")

</div>

yet actually the problem i posed - the was NO ANY redefinition… just multiple script invocations (quite usual so far i can take in for the Julia development cycle )

---

<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 15, 2017, 2:20pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/7 "2017-04-15T14:20:50Z")

</div>

If you include a script with method definitions multiple times, then you are indeed overwriting methods.

---

<div class="post-metadata">

### Author: ![DIzer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dizer/32/3971_2.png) [@DIzer](https://discourse.julialang.org/u/DIzer)
#### Post date: [April 15, 2017, 2:43pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/8 "2017-04-15T14:43:17Z")

</div>

NO I include NO additional scripts,- just rerun main (a single one) - but with a dozen functions in… It worth to note…there was NO any warnings at the FIRST invocation( it spread out on the subsequent)

---

<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 15, 2017, 2:55pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/9 "2017-04-15T14:55:27Z")

</div>

Exactly

---

<div class="post-metadata">

### Author: ![musm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/musm/32/3675_2.png) [@musm](https://discourse.julialang.org/u/musm)
#### Post date: [April 15, 2017, 10:31pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/10 "2017-04-15T22:31:20Z")

</div>

See [https://github.com/Ismael-VC/Suppressor.jl](https://github.com/Ismael-VC/Suppressor.jl)  
which does exactly what you want

```julia
julia> f(x) = 1
f (generic function with 1 method)

julia> @suppress f(x) = 2
2

```

---

<div class="post-metadata">

### Author: ![DIzer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dizer/32/3971_2.png) [@DIzer](https://discourse.julialang.org/u/DIzer)
#### Post date: [April 16, 2017, 12:24am UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/11 "2017-04-16T00:24:11Z")

</div>

Thank you - it works! But the solution is a bit verbose (i do hope for some repl key or option), for i need to wrap in every function i have…  
In the my case it is better than none, but of course -the proper implementation of the feature within jit is still preferred and waited (by me)

---

<div class="post-metadata">

### Author: ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)
#### Post date: [April 16, 2017, 2:40am UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/12 "2017-04-16T02:40:23Z")

</div>

You can `@suppress include(filename)`, I think. Or use [`ClobberingReload.sinclude(filename)`](https://github.com/cstjean/ClobberingReload.jl#silencing-warnings)

---

<div class="post-metadata">

### Author: ![DIzer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dizer/32/3971_2.png) [@DIzer](https://discourse.julialang.org/u/DIzer)
#### Post date: [April 16, 2017, 10:12am UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/13 "2017-04-16T10:12:26Z")

</div>

thanks, i’ll take it in the account when the time to restructure the script is up to come

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [April 16, 2017, 12:15pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/14 "2017-04-16T12:15:05Z")

</div>

> [@DIzer](#):
>
> NO I include NO additional scripts,- just rerun main (a single one) - but with a dozen functions in…

If you aren’t changing the functions, why not put all of your function definitions into a separate file (or module) and include that once?

---

<div class="post-metadata">

### Author: ![DIzer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dizer/32/3971_2.png) [@DIzer](https://discourse.julialang.org/u/DIzer)
#### Post date: [April 16, 2017, 1:39pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/15 "2017-04-16T13:39:46Z")

</div>

Well i have some experience to make scientific computations (and end-user apps) and teaching (at an university ) with traditional programming languages (C, C++,Fortran, Delphi). and of course I KNOW how to develop size scaled program with (not by the hearings and readings). On the other hand// I put an eye on the Julia lang 3 years ago. Some of its KEY ideas and features behind her seemed very disputable to me, but the language and its Eco-infrastructure were too raw (for me) to put the ideas to test. Now i just want to get COMPLEX experience (the language, ide, build in libraries, external packages… ) to solve complex (in sense many-component) small-world problem and to make the opinion of my own. For as a lecturer I MUST have one (if i want to teach somebody it)/ So i do not want to make obvious (for you) things just for “clear experiment” sake.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [April 16, 2017, 5:00pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/16 "2017-04-16T17:00:45Z")

</div>

> [@DIzer](#):
>
> In the my case it is better than none, but of course -the proper implementation of the feature within jit is still preferred and waited (by me)

It’s already implemented. And there’s only one issue left for v0.6

> **[0.6.0 Milestone · JuliaLang/julia](https://github.com/JuliaLang/julia/milestone/20)**
>
> The Julia Programming Language. Contribute to JuliaLang/julia development by creating an account on GitHub.

That one issue already has a WIP PR. In other words. chill a little bit. For now, if you’re not changing around the functions, it doesn’t hurt and is just a warning, and `@suppress` will work fine in a pinch.

---

<div class="post-metadata">

### Author: ![DIzer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dizer/32/3971_2.png) [@DIzer](https://discourse.julialang.org/u/DIzer)
#### Post date: [April 16, 2017, 7:15pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/17 "2017-04-16T19:15:35Z")

</div>

I take it in… and from my hand -tried to clarify my motivations… so let us be over with the topic and i sincerely thank for, everybody who is involved in

---

<div class="post-metadata">

### Author: ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)
#### Post date: [November 4, 2017, 6:48pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/18 "2017-11-04T18:48:59Z")

</div>

You can suppress any expression, including blocks, ie:

```julia
using Suppressor: @suppress_err

@suppress_err begin
    f1() = :foo
    f2() = :bar
    f3() = :baz
end

```

---

<div class="post-metadata">

### Author: ![mdashti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mdashti/32/3454_2.png) [@mdashti](https://discourse.julialang.org/u/mdashti)
#### Post date: [October 29, 2018, 1:01pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/19 "2018-10-29T13:01:21Z")

</div>

Apparently, it does not work anymore with Julia 1.0. Any suggestion?

---

<div class="post-metadata">

### Author: ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)
#### Post date: [October 29, 2018, 1:10pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233/20 "2018-10-29T13:10:39Z")

</div>

FYI, I created an issue [here](https://github.com/JuliaIO/Suppressor.jl/issues/29).

[Next page](https://discourse.julialang.org/t/is-there-a-way-to-suppress-method-overwritten-warnings/3233.md?page=2)
