# Functions inside functions using "global" variables

**URL:** <https://discourse.julialang.org/t/functions-inside-functions-using-global-variables/31434>\
**Category:** Performance\
**Created:** [November 23, 2019, 10:22pm UTC](https://discourse.julialang.org/t/functions-inside-functions-using-global-variables/31434 "2019-11-23T22:22:59Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [November 23, 2019, 11:07pm UTC](https://discourse.julialang.org/t/functions-inside-functions-using-global-variables/31434/2 "2019-11-23T23:07:46Z")

</div>

You’re making a closure, which is a very acceptable thing to do (unless I misunderstand your example). Closures are preformant, except for one bug in Julia: [performance of captured variables in closures · Issue #15276 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/15276)

There was a recent thread discussing work-arounds: [Avoiding Allocations with User provided Closures](https://discourse.julialang.org/t/avoiding-allocations-with-user-provided-closures/31279)

---

_[View the full topic](https://discourse.julialang.org/t/functions-inside-functions-using-global-variables/31434)._
