A MWE for the use case is below:

We have two user defined types:

```
abstract type pow end
struct sep_pow{T<:AbstractFloat} <: pow{T}
power1AU :: T
powMin :: T
powMax :: T
powerModelCofs :: Vector{T}
decayRate :: T
end
struct nuclear_pow{T<:AbstractFloat} <: pow{T}
BOLPow :: T
decayRate :: T
end
```

and there are two functions update functions, one for each type:

```
get_power{T}(x::sep_pow{T}, y::T, z::T) = do something
get_power{T}(x::nuclear_pow{T}, y::T, z::T) = do something
```

Now based on the user input I create an array consisting of user-defined number `nuclear_pow`

and `sep_pow`

types:

```
Arr=Vector{pow{T}}
...
stuff happens
...
Arr = [sep_pow{Float64},sep_pow{Float64},nuclear_pow{Float64},sep_pow{Float64}...]
```

the length of array is dependent on on the user input and the order (and number) in which the two types are present is also user dependent. Finally, this array is then used at the end of each optimization step to compute the cost

Now the compiler doesn’t know at compile time what is the length of these arrays and the order of the functions so calling the `get_power`

function on the whole array results in a dynamic dispatch . The only way I though of mitigating this was via creating two arrays and tracking the order of the two types via another `Integer array`

and using `If loop`

to call the associated `get_power`

function. This seems like a very brute force and complicated approach. Hence this question to seek out a better approach.

thanks!