# How to unspecify parametric arguments

**URL:** <https://discourse.julialang.org/t/how-to-unspecify-parametric-arguments/26427>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 16, 2019, 3:03pm UTC](https://discourse.julialang.org/t/how-to-unspecify-parametric-arguments/26427 "2019-07-16T15:03:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [July 16, 2019, 3:03pm UTC](https://discourse.julialang.org/t/how-to-unspecify-parametric-arguments/26427/1 "2019-07-16T15:03:09Z")

</div>

I want to write a method for a parametric type, where I specify some of the parameters (to have multiple dispatch) but leave some of the others alone, cause they don’t make a difference.  
To my “dismay” this MWE works…

```julia
struct A{T}
    a::T
end

struct B{T}
    b::T
end

struct C{T,S}
    a::T
    b::S
end

fun(c::C{<:A, B{Int}}) = c.b.b + 1
fun(c::C{<:A, B{String}}) = println(c.b.b)

cint = C(A(false), B(1))
fun(cint)

ctxt = C(A(false), B("a"))
fun(ctxt)

```

But in my case I get this error when trying what I think is the same thing. Here are my definitions of two functions (this is completely out of context, so might be hard to follow):

```nohighlight
unction temp2pixel(k, p::POI{<:Calibration,Temporal{<:AbstractTimeLine,Instantaneous}})
    ...
end
function temp2pixel(k, p::POI{<:Calibration,Temporal{<:AbstractTimeLine,Prolonged}})
    ...
end

```

and here’s the error I get when I try to call these functions:

```julia
ERROR: MethodError: no method matching temp2pixel(::Symbol, ::POI{Calibration{Temporal{WholeVideo,Prolonged},Temporal{WholeVideo,Instantaneous}},Temporal{WholeVideo,Instantaneous}})
Closest candidates are:
  temp2pixel(::Any, ::POI{#s7,Temporal{#s5,Instantaneous} where #s5<:AbstractTimeLine} where #s7<:Calibration) at REPL[82]:2
  temp2pixel(::Any, ::POI{#s7,Temporal{#s5,Prolonged} where #s5<:AbstractTimeLine} where #s7<:Calibration) at REPL[83]:2
Stacktrace:
 [1] top-level scope at ./REPL[86]:6 [inlined]
 [2] top-level scope at ./none:0

```

Basically, I have a bunch of parametric types, I want the methods to differentiate on some of these parameters but not all… I’m hoping that instead of reproducing the whole process and creating some convoluted MWE someone here might recognize the error and know what to do 🙂

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [July 16, 2019, 3:42pm UTC](https://discourse.julialang.org/t/how-to-unspecify-parametric-arguments/26427/2 "2019-07-16T15:42:47Z")

</div>

I really hate and recommend against using the `T{<:S}` syntax for this reason… Before you know the syntax, the `<:S` part looks like a first class object but it’s not. After you learn the syntax it seems like it should do what you expect here but it’s not…

What you want is

```julia
p::POI{T1,Temporal{T2,Instantaneous}} where {T2 <: AbstractTimeLine, T1 <: Calibration}

```

What you have is

```julia
p::POI{T1,Temporal{T2,Instantaneous} where {T2 <: AbstractTimeLine}} where {T1 <: Calibration}

```

You can see it in the error message…

```julia
::POI{#s7,Temporal{#s5,Instantaneous} where #s5<:AbstractTimeLine} where #s7<:Calibration

```

The difference between the two is a little subtle and the syntax really hide the difference making it hard for anyone that doesn’t have a lot of experience to catch…

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [July 16, 2019, 8:47pm UTC](https://discourse.julialang.org/t/how-to-unspecify-parametric-arguments/26427/3 "2019-07-16T20:47:07Z")

</div>

Thank you @yuyichao!
