# Function accepting a parametric function

**URL:** <https://discourse.julialang.org/t/function-accepting-a-parametric-function/23106>\
**Category:** General Usage\
**Tags:** question\
**Created:** [April 13, 2019, 1:06pm UTC](https://discourse.julialang.org/t/function-accepting-a-parametric-function/23106 "2019-04-13T13:06:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alan\_Bahm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alan_bahm/32/7742_2.png) [@Alan\_Bahm](https://discourse.julialang.org/u/Alan_Bahm)\
**Post date:** [April 13, 2019, 1:06pm UTC](https://discourse.julialang.org/t/function-accepting-a-parametric-function/23106/1 "2019-04-13T13:06:18Z")

</div>

Hi all,

I am trying to port some code I inherited from Julia 0.6 (via Julia 0.7) into Julia v1.1. The code below worked in v0.6, but errors in v1.1. The approach/syntax is outside of my understanding, in fact I have trouble making a minimal toy example. I looked through the manual and other packages for examples that follow this design, but I couldn’t find anything quite like it.

This code:

```julia
function estimator_convergence_order(est::DerivativeEstimator{Dim}) where Dim
  @assert 1 ≤ Dim ≤ 3
  # ... (more code branching on the value of Dim below)
end

```

fails when accessing Dim (first line) with : `UndefVarError: Dim not defined`

The module has quite a bit of code that uses this design (not having to specify the number of dimensions in the function signature, but branching internally).

I’m not sure if this is a syntax issue, or a design issue, so any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 13, 2019, 2:09pm UTC](https://discourse.julialang.org/t/function-accepting-a-parametric-function/23106/2 "2019-04-13T14:09:26Z")

</div>

It may be a failure somewhere else, since

```julia
struct DerivativeEstimator{Dim} end

function estimator_convergence_order(est::DerivativeEstimator{Dim}) where Dim
  @assert 1 ≤ Dim ≤ 3
  # ... (more code branching on the value of Dim below)
end

estimator_convergence_order(DerivativeEstimator{3}())

```

works fine in Julia 1.x.

> [@Alan\_Bahm](#):
>
> The approach/syntax is outside of my understanding

You should work through the manual up to at least the Methods chapter.

---

<div class="post-metadata">

**Author:** ![Alan\_Bahm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alan_bahm/32/7742_2.png) [@Alan\_Bahm](https://discourse.julialang.org/u/Alan_Bahm)\
**Post date:** [April 14, 2019, 1:11pm UTC](https://discourse.julialang.org/t/function-accepting-a-parametric-function/23106/3 "2019-04-14T13:11:58Z")

</div>

Thanks! I’ll build up the toy example now to find where the issue is.
