# Tuples of Ints as type parameters v0.5/0.6

**URL:** https://discourse.julialang.org/t/tuples-of-ints-as-type-parameters-v0-5-0-6/2751
**Category:** General Usage
**Created:** [March 18, 2017, 7:49pm UTC](https://discourse.julialang.org/t/tuples-of-ints-as-type-parameters-v0-5-0-6/2751 "2017-03-18T19:49:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![gasagna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gasagna/32/1275_2.png) [@gasagna](https://discourse.julialang.org/u/gasagna)
#### Post date: [March 18, 2017, 7:49pm UTC](https://discourse.julialang.org/t/tuples-of-ints-as-type-parameters-v0-5-0-6/2751/1 "2017-03-18T19:49:47Z")

</div>

Hi,

I have a situation where I want to have a few tuples as type parameters. In v0.5 I used to have

```julia
# works in v0.5
immutable foo{a, b, N, T}
    foo{N, T}(a_::NTuple{N, T}, b_::NTuple{N, T}) = new()
end
foo(a, b) = foo{a, b, length(a), eltype(a)}(a, b)
@show foo((1, 2), (3, 4))

```

where the inner constructor enforces the constraint that the lengths of the tuple must be the same.

I am converting my packages to v0.6 but I am not able to achieve the same result. The main difference is that now all type parameters need to be specified in the inner constructor. Here is an example of something that does not work

```julia
# does not work in v0.6
struct foo{a, b, N, T}
    (::foo){a, b, N, T}(a_::NTuple{N, T}, b_::NTuple{N, T}) = new{a, b, N, T}()
end
foo(a, b) = foo{a, b, length(a), eltype(a)}(a, b)
@show foo((1, 2), (3, 4))

```

as the parameters `a, b` do not appear in the function signature.

Thanks,

Davide

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [March 18, 2017, 8:22pm UTC](https://discourse.julialang.org/t/tuples-of-ints-as-type-parameters-v0-5-0-6/2751/2 "2017-03-18T20:22:11Z")

</div>

This works both in 0.5 and 0.6:

```julia
julia> immutable foo{a, b, N, T}
           (::Type{foo{a,b,N,T}}){a,b,N,T}(::NTuple{N, T}, ::NTuple{N, T}) = new{a,b,N,T}()
       end

julia> foo(a, b) = foo{a, b, length(a), eltype(a)}(a, b)
foo{a,b,N,T}

julia> foo((1, 2), (3, 4))
foo{(1,2),(3,4),2,Int64}()

```

If you don’t care about 0.5, this works:

```julia
julia> struct foo{a, b, N, T}
           foo{a,b,N,T}(::NTuple{N, T}, ::NTuple{N, T}) where a where b where N where T = new()
       end

julia> foo(a, b) = foo{a, b, length(a), eltype(a)}(a, b)
foo

julia> foo((1, 2), (3, 4))
foo{(1, 2),(3, 4),2,Int64}()

```

Does anyone know whether the four `where` can somehow be reduced? Answering my own question:

```julia
julia> struct foo{a, b, N, T}
           foo{a,b,N,T}(::NTuple{N, T}, ::NTuple{N, T}) where {a, b, N, T} = new()
       end

```

---

<div class="post-metadata">

### Author: ![gasagna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gasagna/32/1275_2.png) [@gasagna](https://discourse.julialang.org/u/gasagna)
#### Post date: [March 19, 2017, 1:27pm UTC](https://discourse.julialang.org/t/tuples-of-ints-as-type-parameters-v0-5-0-6/2751/3 "2017-03-19T13:27:15Z")

</div>

Thanks @mauro3. Just a question: what is the difference in the inner constructor syntax between

```julia
(::Type{foo{a,b,N,T}}){a,b,N,T}(::NTuple{N, T} ....

```

and

```julia
 foo{a,b,N,T}(::NTuple{N, T} ...

```

in your first and second code blocks?

Thanks!

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [March 19, 2017, 1:42pm UTC](https://discourse.julialang.org/t/tuples-of-ints-as-type-parameters-v0-5-0-6/2751/4 "2017-03-19T13:42:58Z")

</div>

The first one adds a method for `foo{a,b,N,T}` (i.e. all type parameter specified) and can work on both 0.5 and 0.6 without depwarn. The second one adds a method for `foo` and will raise an depwarn on 0.6. If you don’t care about 0.5 compatibility, you can just follow the depwarn.

Also note that in your original version, you defined an inner constructor that does **NOT** match `N` and `T` to the actual type.

```julia
julia> foo{1,1,10000,Int}((1.0,), (1.0,))
foo{1,1,10000,Int64}()

```
