# How to shorten type definition with many AbstractArray fields?

**URL:** <https://discourse.julialang.org/t/how-to-shorten-type-definition-with-many-abstractarray-fields/27301>\
**Category:** General Usage\
**Tags:** type\
**Created:** [August 8, 2019, 7:16am UTC](https://discourse.julialang.org/t/how-to-shorten-type-definition-with-many-abstractarray-fields/27301 "2019-08-08T07:16:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cserteGT3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/csertegt3/32/8283_2.png) [@cserteGT3](https://discourse.julialang.org/u/cserteGT3)\
**Post date:** [August 8, 2019, 7:16am UTC](https://discourse.julialang.org/t/how-to-shorten-type-definition-with-many-abstractarray-fields/27301/1 "2019-08-08T07:16:46Z")

</div>

I have a struct like:

```julia
mutable struct MyType{A<:AbstractArray, B<:AbstractArray, C<:AbstractArray, D<:AbstractArray}
    vertices::A
    normals::B
    subsets::C
    isenabled::BitArray{1}
    size::Int
    levelweight::D
    levelscore::D
end

```

Can I somehow shorten this type definition?  
My only idea is aliasing `AbstractArray`, like:

```julia
const AA = AbstractArray
mutable struct MyType{A<:AA , B<:AA , C<:AA , D<:AA}
    vertices::A
    normals::B
    subsets::C
    isenabled::BitArray{1}
    size::Int
    levelweight::D
    levelscore::D
end

```

---

<div class="post-metadata">

**Author:** ![srb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/srb/32/6812_2.png) [@srb](https://discourse.julialang.org/u/srb)\
**Post date:** [August 8, 2019, 8:04am UTC](https://discourse.julialang.org/t/how-to-shorten-type-definition-with-many-abstractarray-fields/27301/2 "2019-08-08T08:04:37Z")

</div>

Something like this?

```julia
mutable struct MyType{T<:AbstractArray}
    vertices::T
    normals::T
    subsets::T
    isenabled::BitArray{1}
    size::Int
    levelweight::T
    levelscore::T
end

```

---

<div class="post-metadata">

**Author:** ![cserteGT3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/csertegt3/32/8283_2.png) [@cserteGT3](https://discourse.julialang.org/u/cserteGT3)\
**Post date:** [August 8, 2019, 8:28am UTC](https://discourse.julialang.org/t/how-to-shorten-type-definition-with-many-abstractarray-fields/27301/3 "2019-08-08T08:28:26Z")

</div>

AFAIK that way every field has to be same type, which I don’t want.

---

<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 8, 2019, 8:37am UTC](https://discourse.julialang.org/t/how-to-shorten-type-definition-with-many-abstractarray-fields/27301/4 "2019-08-08T08:37:14Z")

</div>

I don’t think there is a better solution than the alias, or just leaving it as is.

TBH, I think it is fine _not_ to specify supertypes for some slots in the definition. It is not necessary for speed, an inner constructor can take care of validation if necessary (in a more general way), and while supertypes have some value as documentation, they can also just get in the way easily.
