While @lmiq covered another possible dimension you might want to consider, I will try to address your question more directly.
Firstly, if you use the parameterized declaration you wrote:
function compute_interaction(particles_i::Vector{T}, particles_j::Vector{T}) where {T <: AbstractParticle}
The resultant method will only trap calls where both vectors are of the same element type, for example:
-
particles_i::Vector{CustomParticle}&particles_j::Vector{CustomParticle} - or
particles_i::Vector{AbstractParticle}&particles_j::Vector{AbstractParticle}
That does not appear to be your intent. Instead, I believe you wanted to compute interactions between particles between any vector with elements that are <:AbstractParticle:
function compute_interaction(particles_i::Vector{T1}, particles_j::Vector{T2}) where {T1 <: AbstractParticle, T2 <: AbstractParticle}
Notice how there are two distinct T1 & T2 that are allowed to be different.
That means this method will also trap calls where the vectors have different element types, for example:
-
particles_i::Vector{CustomParticle}&particles_j::Vector{AbstractParticle} - and
particles_i::Vector{CustomParticle}&particles_j::Vector{Particle} - and all other combinations.
Warning on having two vectors
Having said that, my guess is you probably don’t want to have two vectors. You probably want to loop through all combinations from a single particle vector, and skip the interaction between particle_i and itself.