# Type-annotate vs convert

**URL:** <https://discourse.julialang.org/t/type-annotate-vs-convert/4404>\
**Category:** General Usage\
**Created:** [June 22, 2017, 2:46am UTC](https://discourse.julialang.org/t/type-annotate-vs-convert/4404 "2017-06-22T02:46:14Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Stephen\_Vavasis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stephen_vavasis/32/3389_2.png) [@Stephen\_Vavasis](https://discourse.julialang.org/u/Stephen_Vavasis)\
**Post date:** [June 23, 2017, 12:14pm UTC](https://discourse.julialang.org/t/type-annotate-vs-convert/4404/7 "2017-06-23T12:14:47Z")

</div>

This is a bit of a stretch…

In the following old thread:

> [@Recovering parameter type from parameter list](https://discourse.julialang.org/t/recovering-parameter-type-from-parameter-list/1343):
>
> Suppose I want to be generic as follows: # concepts abstract AbstractFoo{N,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{N,T}} \<: AbstractContainer{F} state::Vector{T} end The code above doesn’t compile because of the malformed parameter list. What is the best way to recover the type T from the type Abs…

I proposed a solution (untested!) to the original poster’s problem. The solution involved a constructor for a type `S` that returned a non-`S`. I believe that this is permitted by the language. Meanwhile, there is a close relationship between constructors and `convert`. So I can imagine that there are situations for constructing complex types in which defining `convert(T,x)` to return a non-`T` might be useful.

---

_[View the full topic](https://discourse.julialang.org/t/type-annotate-vs-convert/4404)._
