Arithmetic on integer type parameters

I’m trying to do something along the likes of

struct Simplex{d}
  vindices::NTuple{d+1,Int}
end

I know of the workaround in this answer but is there some other solution that doesn’t involve changing my type signature?
If not, would this be a reasonable feature request? By declaring d<:Int I feel like the compiler shouldn’t have a problem figuring out simple arithmetic.

No, it’s sort of d::Int but certainly not d<:Int.

No.

Not directly but kind of. This is Proposal: Defer calculation of field types until type parameters are known · Issue #18466 · JuliaLang/julia · GitHub

1 Like

Yes d::Int of course. Thanks for pointing me to the ticket.
There I found the solution (at least for my specific usecase):

struct Simplex{d}
  vindices::Tuple{Int,Vararg{Int,d}}
end
3 Likes