# Creating an anonymous function at the local level. Conflict with const resulting in performance issues

**URL:** <https://discourse.julialang.org/t/creating-an-anonymous-function-at-the-local-level-conflict-with-const-resulting-in-performance-issues/123921>\
**Category:** Performance\
**Created:** [December 17, 2024, 11:52am UTC](https://discourse.julialang.org/t/creating-an-anonymous-function-at-the-local-level-conflict-with-const-resulting-in-performance-issues/123921 "2024-12-17T11:52:45Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![stefkuypers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefkuypers/32/19185_2.png) [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Post date:** [December 17, 2024, 1:23pm UTC](https://discourse.julialang.org/t/creating-an-anonymous-function-at-the-local-level-conflict-with-const-resulting-in-performance-issues/123921/5 "2024-12-17T13:23:36Z")

</div>

Thanks!

I oversimplified the code though. The call to sim\_function happens deeper in the call stack, not at the top level in the iteration loop. So it’s within a function that is called within the iteration loop of the simulation.

I guess I’ll need to drop the anonymous function solution and store the data in the model (in the full implementation I can store arbitrary data in the model). I just found the anonymous function solution more elegant.

---

_[View the full topic](https://discourse.julialang.org/t/creating-an-anonymous-function-at-the-local-level-conflict-with-const-resulting-in-performance-issues/123921)._
