# More flexible parametric types

**URL:** <https://discourse.julialang.org/t/more-flexible-parametric-types/129671>\
**Category:** General Usage\
**Tags:** parametric-types\
**Created:** [June 5, 2025, 1:03pm UTC](https://discourse.julialang.org/t/more-flexible-parametric-types/129671 "2025-06-05T13:03:32Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![FerreolS](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ferreols/32/216854_2.png) [@FerreolS](https://discourse.julialang.org/u/FerreolS)\
**Post date:** [June 6, 2025, 9:32pm UTC](https://discourse.julialang.org/t/more-flexible-parametric-types/129671/11 "2025-06-06T21:32:01Z")

</div>

I think it is linked to one of my [question about operation on type parameter](https://discourse.julialang.org/t/relation-between-type-parameter). I don’t think it is possible to make complex operations on type parameter to explicit link `E` with all different type `T1, T2,...`. However if `E` appears in one of this type parameter, ( let say `T1 == E` or `T1 = Array{N,E}` then you can create an alias as proposed by @VinceNeede and rely on inner constructor to enforce its structure:

```julia
struct B{T1,T2,T3,T4}
               F1 :: T1
               F2 :: Vector{ T1 }
               F3 :: T2
               F4 :: Complex{T1}
              #default
              B(f1::T1, f2::T2, f3::T3, f4::T4) where {T1,T2,T3,T4} = error("building B{$T1,$T2,$T3,$T4}")
              # T1 <: Real
              B(f1::T1, f2::Vector{T1}, f3::Int, f4::Complex{T1}) where {T1<:Real} = new{T1,Vector{T1},Int,Complex{T1}}(f1,f2,f3,f4)
end

S{E} = B{E,T2,T3,T4} where {T2,T3,T4}

```

Then you can dispatch on S{E} and the following function should work

```julia
function foo( x :: S{E} ) where E
	
end

```

If you don’t want to write all inner constructors for a large number of `E` then you can rely on generated functions.

---

_[View the full topic](https://discourse.julialang.org/t/more-flexible-parametric-types/129671)._
