Your question presupposes that you can write useful generic code with the
return result, but does not provide any context on your problem. When a
similar question was asked previously on the mailing list, I recall
pointing out that the code the author was attempting to write was not going
to function as intended. Perhaps you can provide some more context?

The observation that I am making is that you cannot arbitrarily pick apart
a type and expect everything to line up afterwards. For example, it is
possible to have the following:
abstract AbstractTy{A,B}
type Ty1 <: AbstractTy{Int, Float64} end
type Ty2{B,A} <: AbstractTy{A,B} end

So you can't generically reconstruct some arbitrary subtype by some generic
rearrangement of its type parameters.

On Tue, Apr 21, 2015 at 4:34 PM Mauro <[email protected]> wrote:

> I have a parameterized type and want to get the primary-type.  For
> example, I got
>
> a = Array{Int,2}
>
> is there a type-stable way to get Array?  This is non-type stable:
>
> f(t::Type) = t.name.primary
>
> as the inferred return type is Type.
>
> This does not work:
>
> f{T, S}(::Type{T{S...}}) = T
>
> Any ideas? Thanks, M
>

Reply via email to