# Redefining methods in Base

**URL:** <https://discourse.julialang.org/t/redefining-methods-in-base/30329>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [October 26, 2019, 10:25am UTC](https://discourse.julialang.org/t/redefining-methods-in-base/30329 "2019-10-26T10:25:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Post date:** [October 26, 2019, 10:25am UTC](https://discourse.julialang.org/t/redefining-methods-in-base/30329/1 "2019-10-26T10:25:09Z")

</div>

Just curious. It looks like that something as Base.:+(a,b)= a\*b has no effect.  
Does Julia not allow redefining methods in Base? If so, what would be rationale behind it?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 26, 2019, 10:35am UTC](https://discourse.julialang.org/t/redefining-methods-in-base/30329/2 "2019-10-26T10:35:47Z")

</div>

Do you really want to get 5+6 as 30?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 26, 2019, 10:41am UTC](https://discourse.julialang.org/t/redefining-methods-in-base/30329/3 "2019-10-26T10:41:50Z")

</div>

> [@Sijun](#):
>
> It looks like that something as Base.:+(a,b)= a\*b has no effect.

Just guessing here, but you are probably just testing the effect incorrectly, e.g. `Int` + `Int` has a more special method that will be called even after your definition.

---

<div class="post-metadata">

**Author:** ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Post date:** [October 26, 2019, 10:43am UTC](https://discourse.julialang.org/t/redefining-methods-in-base/30329/4 "2019-10-26T10:43:54Z")

</div>

No not really. 🙂  
If such thing is allowed, it would be possible to define such as Base.:+(a::CustomType, b::CustomType) as you wish.

---

<div class="post-metadata">

**Author:** ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Post date:** [October 26, 2019, 10:47am UTC](https://discourse.julialang.org/t/redefining-methods-in-base/30329/5 "2019-10-26T10:47:53Z")

</div>

Oh I see. Base.:+(a::CustomType, b::CustomType) does work indeed. Int + Int seems to be handled specially.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [October 26, 2019, 3:11pm UTC](https://discourse.julialang.org/t/redefining-methods-in-base/30329/6 "2019-10-26T15:11:41Z")

</div>

> [@Sijun](#):
>
> Int + Int seems to be handled specially.

It’s not special, it’s multiple dispatch! One of Julia’s not-so-secret sauces [Methods · The Julia Language](https://docs.julialang.org/en/v1/manual/methods/index.html)

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [October 26, 2019, 3:19pm UTC](https://discourse.julialang.org/t/redefining-methods-in-base/30329/7 "2019-10-26T15:19:43Z")

</div>

> [@Sijun](#):
>
> Base.:+(a,b)= a\*b

You can do `Base.:+(a::Int, b::Int) = a * b` but Julia won’t survive long enough for you to enjoy it, since it totally breaks the internals.

---

<div class="post-metadata">

**Author:** ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Post date:** [October 26, 2019, 3:37pm UTC](https://discourse.julialang.org/t/redefining-methods-in-base/30329/8 "2019-10-26T15:37:01Z")

</div>

@kevbonham, @GunnarFarneback, A-ha, yes, indeed. Thanks!
