# Block Array constructor in 0.7.0-rc2

**URL:** <https://discourse.julialang.org/t/block-array-constructor-in-0-7-0-rc2/12947>\
**Category:** General Usage\
**Created:** [August 6, 2018, 4:49pm UTC](https://discourse.julialang.org/t/block-array-constructor-in-0-7-0-rc2/12947 "2018-08-06T16:49:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacobadenbaum](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jacobadenbaum](https://discourse.julialang.org/u/jacobadenbaum)\
**Post date:** [August 6, 2018, 4:49pm UTC](https://discourse.julialang.org/t/block-array-constructor-in-0-7-0-rc2/12947/1 "2018-08-06T16:49:21Z")

</div>

Does anyone know why the following code returns true on julia 0.6.4 but false on 0.7.0-rc2? It looks like the way that array constructors are parsed may have changed, but I can’t find it in the News.md. Does anyone know how to overload the array constructor on 0.7 the same way I could on 0.6.4?

```julia
import Base: hcat, vcat, ==
mutable struct Foo{T,N}
    x::Array{T,N}
end
Foo(x) = Foo(vcat(x))

hcat(a::Foo, b::Foo) = Foo(hcat(a.x,b.x))
vcat(a::Foo, b::Foo) = Foo(vcat(a.x,b.x))
==(a::Foo, b::Foo) = a.x == b.x

[Foo(5) Foo(6); Foo(7) Foo(8)] == Foo([5 6; 7 8])
# true on 0.6.4
# false on 0.7.0-rc2

```

In particular, on 0.6.4:

```julia
julia> [Foo(5) Foo(6); Foo(7) Foo(8)]
Foo{Int64,2}([5 6; 7 8])

```

but on 0.7.0-rc2 I get:

```julia
julia> [Foo(5) Foo(6); Foo(7) Foo(8)]
2×2 Array{Foo{Int64,1},2}:
 Foo{Int64,1}([5]) Foo{Int64,1}([6])
 Foo{Int64,1}([7]) Foo{Int64,1}([8])

```

---

<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:** [August 6, 2018, 6:15pm UTC](https://discourse.julialang.org/t/block-array-constructor-in-0-7-0-rc2/12947/2 "2018-08-06T18:15:40Z")

</div>

`[Foo(5) Foo(6); Foo(7) Foo(8)]` is lowered as `hvcat` in both versions, but v0.6 implements it using `hcat` and `vcat`, while in `v0.7` there is a direct implementation.

You may have been relying on an implementation detail. Perhaps provide a method for `hvcat`, but it is slight abuse since that should return an `<: AbstractMatrix`.

---

<div class="post-metadata">

**Author:** ![jacobadenbaum](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jacobadenbaum](https://discourse.julialang.org/u/jacobadenbaum)\
**Post date:** [August 6, 2018, 6:20pm UTC](https://discourse.julialang.org/t/block-array-constructor-in-0-7-0-rc2/12947/3 "2018-08-06T18:20:58Z")

</div>

Yeah I think that’s what was going on. I solved the problem by copying a version of the old hvcat fallback and explicitly specializing it so it only applies to my types.

More generally, I like the ability to overload the block array constructor, and have used it in [TexTables.jl](https://github.com/jacobadenbaum/TexTables.jl) to make it easy to put tables together with the block array syntax. Since horizontal and vertical concatenation of tables makes a lot of sense in this context, I thought it was natural to overload the hcat and vcat operators. Maybe I shouldn’t abuse them in quite this way…
