# Does it matter where in the code a function is defined?

**URL:** <https://discourse.julialang.org/t/does-it-matter-where-in-the-code-a-function-is-defined/5737>\
**Category:** General Usage\
**Created:** [September 5, 2017, 11:42pm UTC](https://discourse.julialang.org/t/does-it-matter-where-in-the-code-a-function-is-defined/5737 "2017-09-05T23:42:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tparker](https://avatars.discourse-cdn.com/v4/letter/t/839c29/32.png) [@tparker](https://discourse.julialang.org/u/tparker)\
**Post date:** [September 5, 2017, 11:42pm UTC](https://discourse.julialang.org/t/does-it-matter-where-in-the-code-a-function-is-defined/5737/1 "2017-09-05T23:42:24Z")

</div>

The documentation for “Metaprogramming” says “Calling any function that is defined after the body of the generated function … should not be attempted.” I can’t find any other mention of whether it matters where in the code a function is first defined (e.g. before vs. after it is first called). Are there any other situations where this matters at all? Presumably the function needs to be defined either in the namespace in which it’s called or in an imported module - are there any other restrictions?

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [September 6, 2017, 12:11am UTC](https://discourse.julialang.org/t/does-it-matter-where-in-the-code-a-function-is-defined/5737/2 "2017-09-06T00:11:43Z")

</div>

> [@tparker](#):
>
> Are there any other situations where this matters at all?

Well, don’t call something before it’s defined but no, nothing other than this should matter. The order and namespace the function is defined in does not matter as long as they are within scope/accessible.

---

<div class="post-metadata">

**Author:** ![tparker](https://avatars.discourse-cdn.com/v4/letter/t/839c29/32.png) [@tparker](https://discourse.julialang.org/u/tparker)\
**Post date:** [September 6, 2017, 12:26am UTC](https://discourse.julialang.org/t/does-it-matter-where-in-the-code-a-function-is-defined/5737/3 "2017-09-06T00:26:02Z")

</div>

Sorry, in retrospect this was a really stupid question.
