# Parametric type parameter calculation for supertype

**URL:** <https://discourse.julialang.org/t/parametric-type-parameter-calculation-for-supertype/2427>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 3, 2017, 3:20pm UTC](https://discourse.julialang.org/t/parametric-type-parameter-calculation-for-supertype/2427 "2017-03-03T15:20:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)\
**Post date:** [March 3, 2017, 3:20pm UTC](https://discourse.julialang.org/t/parametric-type-parameter-calculation-for-supertype/2427/1 "2017-03-03T15:20:44Z")

</div>

Is it possible to define a type

```julia
abstract Bar{PtrT,N} <: AbstractArray{T,N}

```

Such that `PtrT` is a `Ptr{T}`? i.e. I want Bar to be defined in terms of a pointer type, but have it implement the AbstractArray interface for the pointed-to type, without explicitly specifying the pointed-to type T in the parameterlist of Bar.

---

<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:** [March 3, 2017, 3:42pm UTC](https://discourse.julialang.org/t/parametric-type-parameter-calculation-for-supertype/2427/2 "2017-03-03T15:42:44Z")

</div>

Just use T as parameter and use `Ptr{T}` where you need to?

---

<div class="post-metadata">

**Author:** ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)\
**Post date:** [March 3, 2017, 4:18pm UTC](https://discourse.julialang.org/t/parametric-type-parameter-calculation-for-supertype/2427/3 "2017-03-03T16:18:11Z")

</div>

The problem is Bar here comes from C++ and expects an array-like type as first parameter, not a scalar type. I was a bit disappointed this failed:

```julia
getparam{T}(::Type{Ptr{T}}) = T
type Bar{T,N} <: AbstractArray{getparam(T),N} end

```

It would be cool to have `getparam` execute when the type is instantiated with concrete parameters, instead of right away. At least if that wouldn’t cause breakage for other use cases.

I think I can still make your solution work by changing the C+±to-Julia type mapping, though.

---

<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:** [March 3, 2017, 4:38pm UTC](https://discourse.julialang.org/t/parametric-type-parameter-calculation-for-supertype/2427/4 "2017-03-03T16:38:06Z")

</div>

> [@barche](#):
>
> It would be cool to have getparam execute when the type is instantiated with concrete parameters, instead of right away. At least if that wouldn’t cause breakage for other use cases.

It’ll make dispatch undecidable.
