# Recovering parameter type from parameter list

**URL:** <https://discourse.julialang.org/t/recovering-parameter-type-from-parameter-list/1343>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 7, 2017, 3:20pm UTC](https://discourse.julialang.org/t/recovering-parameter-type-from-parameter-list/1343 "2017-01-07T15:20:58Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 9, 2017, 5:50am UTC](https://discourse.julialang.org/t/recovering-parameter-type-from-parameter-list/1343/5 "2017-01-09T05:50:28Z")

</div>

Thank you @fengyang.wang, I find this approach adopted in Base a little complicated because after all we have a container of `Foo`, and not a container of `Foo` and `T`.

I tried refactoring the code a la C++ as follows:

```julia
# concepts
abstract AbstractFoo{N,T}
dimension{N,T}(::AbstractFoo{N,T}) = N
coordtype{N,T}(::AbstractFoo{N,T}) = T

abstract AbstractContainer{F}

# partial specialization where we fix T = Float64
immutable Foo{N} <: AbstractFoo{N,Float64} end

# a container of AbstractFoo{N,T} where we save state in a vector of T
immutable Container{F<:AbstractFoo} <: AbstractContainer{F}
  state::Vector{coordtype(F)}
end

```

but it returns the error:

> ERROR: MethodError: no method matching coordtype(::TypeVar)

There is any workaround for this error? What is a better approach? I believe this is a very common issue that could also be part of a FAQ somewhere.

---

_[View the full topic](https://discourse.julialang.org/t/recovering-parameter-type-from-parameter-list/1343)._
