# Variable integer type parameter

**URL:** <https://discourse.julialang.org/t/variable-integer-type-parameter/3345>\
**Category:** General Usage\
**Tags:** question\
**Created:** [April 23, 2017, 11:38am UTC](https://discourse.julialang.org/t/variable-integer-type-parameter/3345 "2017-04-23T11:38:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mobius-eng](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mobius-eng/32/99_2.png) [@mobius-eng](https://discourse.julialang.org/u/mobius-eng)\
**Post date:** [April 23, 2017, 11:38am UTC](https://discourse.julialang.org/t/variable-integer-type-parameter/3345/1 "2017-04-23T11:38:35Z")

</div>

Consider the definition of the geometrical domain in N-dimensional space, meshed into sub-domains. And if we want to keep its boundary mesh (e.g. for boundary conditions) we would want to write something like this:

```julia
type Domain{N}
  volumes :: Array{Float64, N}
  boundaryareas :: Array{Float64, N-1}
  ...
end

```

(a bit artificial, but it illustrates the problem) Notice, `boundaryareas` must be one dimension smaller compared to volumes. But currently Julia will throw an error on `N-1`. Is there any other way to express the idea “I want this to be of dimension `N` and this of dimension `N-1` (or `N+1`) and this relation should always be satisfied”?

---

<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:** [April 23, 2017, 1:29pm UTC](https://discourse.julialang.org/t/variable-integer-type-parameter/3345/2 "2017-04-23T13:29:58Z")

</div>

Use two parameters and ensure the invariance in an inner constructor.

---

<div class="post-metadata">

**Author:** ![rleegates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rleegates/32/1029_2.png) [@rleegates](https://discourse.julialang.org/u/rleegates)\
**Post date:** [April 23, 2017, 6:05pm UTC](https://discourse.julialang.org/t/variable-integer-type-parameter/3345/3 "2017-04-23T18:05:40Z")

</div>

On v0.6 you might also want to take a look at the experimental [ComputedFieldTypes.jl](https://github.com/vtjnash/ComputedFieldTypes.jl) and the (speculative) issue [#18466](https://github.com/JuliaLang/julia/issues/18466) on the 1.0 milestone.
