# Is there a discrepancy betweeen use of :: and \<: in function versus struct definitions

**URL:** <https://discourse.julialang.org/t/is-there-a-discrepancy-betweeen-use-of-and-in-function-versus-struct-definitions/26304>\
**Category:** Internals & Design\
**Created:** [July 12, 2019, 10:07pm UTC](https://discourse.julialang.org/t/is-there-a-discrepancy-betweeen-use-of-and-in-function-versus-struct-definitions/26304 "2019-07-12T22:07:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robot-uprising](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robot-uprising/32/4608_2.png) [@robot-uprising](https://discourse.julialang.org/u/robot-uprising)\
**Post date:** [July 12, 2019, 10:07pm UTC](https://discourse.julialang.org/t/is-there-a-discrepancy-betweeen-use-of-and-in-function-versus-struct-definitions/26304/1 "2019-07-12T22:07:41Z")

</div>

for example:

function foo(x::Real)  
…  
end

struct bar{N\<:Real}  
x::N  
end

Why use :: for function, and \<: for struct? I get an error with:

struct bar{N::Real}  
x::N  
end

---

<div class="post-metadata">

**Author:** ![robot-uprising](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robot-uprising/32/4608_2.png) [@robot-uprising](https://discourse.julialang.org/u/robot-uprising)\
**Post date:** [July 12, 2019, 10:37pm UTC](https://discourse.julialang.org/t/is-there-a-discrepancy-betweeen-use-of-and-in-function-versus-struct-definitions/26304/2 "2019-07-12T22:37:53Z")

</div>

Someone answered this on Slack. Julia currently does not have the ability to specify concrete type constraints in generic struct definitions.

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [July 13, 2019, 12:04am UTC](https://discourse.julialang.org/t/is-there-a-discrepancy-betweeen-use-of-and-in-function-versus-struct-definitions/26304/3 "2019-07-13T00:04:54Z")

</div>

True, but there’s also no inconsistency here. `::` is a typeof annotation, while `<:` is a subtype annotation. For example, you could have the following:

```julia
f(x::N) where {N<:Real}

```

In both cases `N` is a type, that’s constrained to be a subtype of `Real`, which `x` is a value constrained to be of type `N`.
