# Interdependent files in module

**URL:** https://discourse.julialang.org/t/interdependent-files-in-module/9675
**Category:** General Usage
**Created:** [March 12, 2018, 11:42pm UTC](https://discourse.julialang.org/t/interdependent-files-in-module/9675 "2018-03-12T23:42:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Robert\_Honig](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robert_honig/32/4930_2.png) [@Robert\_Honig](https://discourse.julialang.org/u/Robert_Honig)
#### Post date: [March 12, 2018, 11:42pm UTC](https://discourse.julialang.org/t/interdependent-files-in-module/9675/1 "2018-03-12T23:42:28Z")

</div>

Say I have the following module definition:

```julia
module Foo
include("bar.jl")
include("baz.jl")
include("qux.jl")
end

```

`bar.jl` uses a function provided by `qux.jl`. What is the julian way to handle this sort of intermodular dependency? Should we just order the files in an order that satisfies all requirements, or is there a neater approach?

---

<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: [March 13, 2018, 4:40am UTC](https://discourse.julialang.org/t/interdependent-files-in-module/9675/2 "2018-03-13T04:40:49Z")

</div>

> [@Robert\_Honig](#):
>
> just order the files in an order that satisfies all requirements

That’s the simplest solution, if you want to keep everything in the same module.

---

<div class="post-metadata">

### Author: ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)
#### Post date: [March 13, 2018, 6:38am UTC](https://discourse.julialang.org/t/interdependent-files-in-module/9675/3 "2018-03-13T06:38:46Z")

</div>

Or add a function definition with no method at the beginning of the module

```julia
function f end

```

This way you can have `bar.jl` use `baz.jl` functions and the other way around. See [https://docs.julialang.org/en/latest/manual/methods/#Empty-generic-functions-1](https://docs.julialang.org/en/latest/manual/methods/#Empty-generic-functions-1).

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [March 13, 2018, 7:04am UTC](https://discourse.julialang.org/t/interdependent-files-in-module/9675/4 "2018-03-13T07:04:37Z")

</div>

For functions the order should not matter, if you only call them in the function body, e.g.

```julia
julia> module Foo
       bar() = baz()
       baz() = "Hello, world!"
       end
Foo

julia> Foo.bar()
"Hello, world!"

```

The ordering matters however if you use the function in the function signature, e.g.

```julia
julia> module Foo
       bar(::typeof(baz)) = baz()
       baz() = "Hello, world!"
       end
ERROR: UndefVarError: baz not defined

```
