# Weird parsing inside \[...\]

**URL:** <https://discourse.julialang.org/t/weird-parsing-inside/11910>\
**Category:** General Usage\
**Created:** [June 24, 2018, 2:49pm UTC](https://discourse.julialang.org/t/weird-parsing-inside/11910 "2018-06-24T14:49:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gdkrmr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdkrmr/32/2791_2.png) [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Post date:** [June 24, 2018, 2:49pm UTC](https://discourse.julialang.org/t/weird-parsing-inside/11910/1 "2018-06-24T14:49:21Z")

</div>

The following is a really hard to spot parsing nuance:

```julia
julia> [0 -1]
1×2 Array{Int64,2}:
 0 -1

julia> [0-1]
1-element Array{Int64,1}:
 -1

julia> [0 - 1]
1-element Array{Int64,1}:
 -1

julia> 0 -1
-1

```

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [June 24, 2018, 8:01pm UTC](https://discourse.julialang.org/t/weird-parsing-inside/11910/2 "2018-06-24T20:01:49Z")

</div>

This is no weird at all, it is how arrays work. If you used MATLAB before, you should know that spaces inside `[]` mean new columns, except for operators `- + * / ...`, they must be evaluated first, the same holds in Julia.

This means:

```julia
[0 -1] => hcat(0, -1)
[0-1] => [-1]
[0 - 1] => [-1]

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 25, 2018, 6:21am UTC](https://discourse.julialang.org/t/weird-parsing-inside/11910/3 "2018-06-25T06:21:38Z")

</div>

Still, there is a tendency in Julia to warn or deprecate ambiguous syntax, eg in v0.7 the following were fixed:

[https://github.com/JuliaLang/julia/issues/16356](https://github.com/JuliaLang/julia/issues/16356)

[https://github.com/JuliaLang/julia/issues/19089](https://github.com/JuliaLang/julia/issues/19089)

So discussion about this would not be without precedent. I vaguely recall an issue which had something to do with `[0 - 1]`, but can’t find it ATM.

---

<div class="post-metadata">

**Author:** ![gdkrmr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdkrmr/32/2791_2.png) [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Post date:** [June 25, 2018, 6:48am UTC](https://discourse.julialang.org/t/weird-parsing-inside/11910/4 "2018-06-25T06:48:02Z")

</div>

These things can be really hard to spot if you don’t know what you are looking for, it reminds me of R’s `x<-y`.
