# Parametric subtyping \`where\` syntax

**URL:** https://discourse.julialang.org/t/parametric-subtyping-where-syntax/5634
**Category:** New to Julia
**Created:** [August 30, 2017, 5:50pm UTC](https://discourse.julialang.org/t/parametric-subtyping-where-syntax/5634 "2017-08-30T17:50:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![stefanocampanella](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefanocampanella/32/3038_2.png) [@stefanocampanella](https://discourse.julialang.org/u/stefanocampanella)
#### Post date: [August 30, 2017, 5:50pm UTC](https://discourse.julialang.org/t/parametric-subtyping-where-syntax/5634/1 "2017-08-30T17:50:16Z")

</div>

Does the following piece of code (which works properly)

```julia
struct MyArray{T<:Number} <: AbstractArray{T,1}
  data::Array{T,1}
end

```

have an equivalent `where` syntax?

I tried the following

```julia
struct MyArray{T} where T<:Number <: AbstractArray{T,1}
  data::Array{T,1}
end

```

but I got

```julia
ERROR: syntax: invalid type signature
Stacktrace:
 [1] macro expansion at ./REPL.jl:97 [inlined]
 [2] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73

```

If is true that subtyping doesn’t admit the `where` syntax, what is the reason behind?

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [August 30, 2017, 6:11pm UTC](https://discourse.julialang.org/t/parametric-subtyping-where-syntax/5634/2 "2017-08-30T18:11:49Z")

</div>

My understanding of this was that the `where` syntax was created specifically for functions, in order to avoid the ambiguity between type parameter arguments in constructors and static type parameters in non-constructor function calls. Since no such ambiguity exists when declaring a `struct`, my assumption has been that the `where` syntax is invalid there (the issue is handled by the various constructors).

For example, in the old syntax  
`f{T<:Real}(phi::T) = exp(im*phi)`  
can either be a function which is called like `f(phi)` or a constructor which is called like `f{T}(phi)`. In the new syntax  
`f(phi::T) where T<:Real = exp(im*phi)`  
makes it clear that this can only be called as `f(phi)`.
