`@nospecialize` on type parameter

This is mostly out of curiosity: Say that I have a struct with a lot of type parameters. One of those parameters changes each run, and I don’t want to specialize on it. Is there any way I can get something like the following to work?

function f(x::Array{@nospecialize(T),N}) where {T,N}
    return x
end

In other words, I want to do codegen for each new N, but not for each new eltype T.

3 Likes

No, not yet anyhow. See Function over-specialization on unused parts of types · Issue #26834 · JuliaLang/julia · GitHub

3 Likes