Not always the punishment associated with splatting, but determining where it is effective is not always obvious (or easy). Your trivial example is actually as efficient as writing A[16,45,6,40,3] = 100. You can see it by comparing
function f(A)
tup = (16,45,6,40,3)
A[tup...] = 100
A
end
function g(A)
A[16,45,6,40,3] = 100
A
end
julia> code_llvm(f, Tuple{Array{Int, 5}})
julia> code_llvm(g, Tuple{Array{Int, 5}})
, . @allocated code_llvm @jl_pgcstack - , . , , , , splatting. , , ... splatting. @code_warntype, . , :
function h(A)
tup = ntuple(x->x+1, 5)
A[tup...] = 100
A
end
julia> code_warntype(h, Tuple{Array{Int,5}})
, , tup.