Subtype of template parameter

Is there a way to implement something like the following:

abstract type T1{T} <: T

I’m creating a type which sometimes acts like a Real (and I want to use it in packages that require Real) and sometimes acts like <: AbstractVector{Real}.

This isn’t possible currently. Why do you want to do this? There may be a different way to set things up that works.

I want to build a type which can be passed into Distributions as scalar parameters. These are Real. However, my type can also be a Vector for other purposes.

Why do you need something which sometimes behaves as an array, and sometimes as a scalar? This feels like a case where you should just have 2 different types.

1 Like

I’d then have to replicate a lot of code to implement each. Anyway, I understand it can’t be done in julia.