# What is the purpose of this function definition in Wavelets package?

**URL:** https://discourse.julialang.org/t/what-is-the-purpose-of-this-function-definition-in-wavelets-package/24236
**Category:** New to Julia
**Created:** [May 15, 2019, 11:38am UTC](https://discourse.julialang.org/t/what-is-the-purpose-of-this-function-definition-in-wavelets-package/24236 "2019-05-15T11:38:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Iulian.Cioarca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iulian.cioarca/32/30166_2.png) [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)
#### Post date: [May 15, 2019, 11:38am UTC](https://discourse.julialang.org/t/what-is-the-purpose-of-this-function-definition-in-wavelets-package/24236/1 "2019-05-15T11:38:46Z")

</div>

I like to look inside different Julia packages to get familiar with the syntax and sometimes find function definitions like this (example from Wavelets package):

```julia
function dwt end

```

And later on in the same file(a part of a for loop):

```julia
for (Xwt, Xwt!, _Xwt!, fw) in ((:dwt, :dwt!, :_dwt!, true),
                                (:idwt, :idwt!, :_dwt!, false))
@eval begin
    # filter
    function ($Xwt)(x::DWTArray{T}, filter::OrthoFilter,
                    L::Integer=maxtransformlevels(x)) where T<:ValueType
        y = Array{T}(undef, size(x))
        return ($_Xwt!)(y, x, filter, L, $fw)
    end

```

Another example from the Tracker package:

```julia
function _forward end

function track(f::F, xs...; kw...) where F
  y, back = _forward(f, xs...; kw...)
  track(Call(back, tracker.(xs)), y)
end

```

Can anyone please explain the purpose and how this works?

Thank you

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [May 15, 2019, 11:54am UTC](https://discourse.julialang.org/t/what-is-the-purpose-of-this-function-definition-in-wavelets-package/24236/2 "2019-05-15T11:54:27Z")

</div>

> [@Iulian.Cioarca](#):
>
> function dwt end

This definition only introduces the name `dwt`, maybe to attach a docstring to it or to define an interface to allow other packages to add methods to it.

The loop performs code generation. It defines a list of functions with similar input signature, see the relevant docs [Metaprogramming · The Julia Language](https://docs.julialang.org/en/v1/manual/metaprogramming/#Code-Generation-1)

I don’t know what your question regarding the last function definition is.

---

<div class="post-metadata">

### Author: ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)
#### Post date: [May 15, 2019, 3:50pm UTC](https://discourse.julialang.org/t/what-is-the-purpose-of-this-function-definition-in-wavelets-package/24236/3 "2019-05-15T15:50:29Z")

</div>

`dwt` = Discrete Wavelet Transform, it is generated code, since other function definitions are similar, they are created using metaprogramming.

Creating the blank function with no methods first is probably so that there isn’t an error in some code generation process when name is needed.

It might be that the progammer inserted the blank functions just to keep track of the naming conventions, and serves no other purpose also.
