# Julia quirks (v. 1.9.0 and higher)

**URL:** https://discourse.julialang.org/t/julia-quirks-v-1-9-0-and-higher/108098
**Category:** General Usage
**Tags:** examples
**Created:** [December 27, 2023, 2:54pm UTC](https://discourse.julialang.org/t/julia-quirks-v-1-9-0-and-higher/108098 "2023-12-27T14:54:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![KZiemian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kziemian/32/9020_2.png) [@KZiemian](https://discourse.julialang.org/u/KZiemian)
#### Post date: [December 27, 2023, 2:54pm UTC](https://discourse.julialang.org/t/julia-quirks-v-1-9-0-and-higher/108098/1 "2023-12-27T14:54:41Z")

</div>

I’m a huge fan of Julia compiler, even if my knowledge of it is very limited. As you should expected with such complicated program it has few quirks that we should be aware of. Since I’m not advanced Julia programmer, I will just post here what I found in Julia 1.9.3 and ask you for more examples of quirky behaviour.

In one tutorial they said that this code is illegal (it would be in C-derived languages and many others):  
`x + y = 2`  
It compiles and gives you generic function with 1 method. Now we have  
`julia> 1 + 3`  
`2`

---

<div class="post-metadata">

### Author: ![mihalybaci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihalybaci/32/13528_2.png) [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)
#### Post date: [December 27, 2023, 3:01pm UTC](https://discourse.julialang.org/t/julia-quirks-v-1-9-0-and-higher/108098/2 "2023-12-27T15:01:34Z")

</div>

This is the largest collection of quirks I’m familiar with

> [@A most harrowing collection of Julia WATs](https://discourse.julialang.org/t/a-most-harrowing-collection-of-julia-wats/77323):
>
> Hello all! wave I’ve been collecting a few of the most cursed corner cases of Julia [WATs](https://www.destroyallsoftware.com/talks/wat) that [I know of here](https://miguelraz.github.io/blog/juliawats/) (WIP), but I would appreciate if people could share their own rare specimens as well. Please ping me with your contributions and I’ll post with proper credit. Here’s an example of what I mean by a Julia WAT: julia\> e = 9998.0 9998.0 julia\> 2e 19996.0 julia\> 2e+4 20000.0 julia\> 2e+5 # This should be 20001.0, right? 200000.0 julia\> 2e + 5 # note the spacing 20001.0 …wat. Some of…

---

<div class="post-metadata">

### Author: ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)
#### Post date: [December 27, 2023, 3:03pm UTC](https://discourse.julialang.org/t/julia-quirks-v-1-9-0-and-higher/108098/3 "2023-12-27T15:03:26Z")

</div>

Although:

 ![Screenshot 2023-12-27 at 15.02.34](https://global.discourse-cdn.com/julialang/original/3X/4/6/4619bd111e91c1a21931a054bbe197dcb9225ef3.png)

---

<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: [December 27, 2023, 3:23pm UTC](https://discourse.julialang.org/t/julia-quirks-v-1-9-0-and-higher/108098/4 "2023-12-27T15:23:27Z")

</div>

`+` is just a normal function in Julia. When you write `+` you typically execute the `Base.:+` function (which is implicitly imported into modules) but (as with any other function) you can shadow outer functions:

```julia
julia> a + b = 1
+ (generic function with 1 method)

julia> 1+2
1

```

Now, you can not shadow a function if you have already used it and resolved to some other function:

```julia
julia> 1+2
3

julia> a + b = 1
ERROR: invalid method definition in Main: function Base.+ must be explicitly imported to be extended

```

And even if you define `a + b = 1` as in the first example, that doesn’t mean that all of Julia’s math is suddenly wrong. All the other places using `+` still resolves to `Base.:+` which is unchanged:

```julia
julia> a + b = 1
+ (generic function with 1 method)

julia> 1 + 2
1

julia> Base.:+(1, 2)
3

```
