# In closure, compile away a step in a calculation internal to some function called in a closure?

**URL:** <https://discourse.julialang.org/t/in-closure-compile-away-a-step-in-a-calculation-internal-to-some-function-called-in-a-closure/105765>\
**Category:** Internals & Design\
**Created:** [November 3, 2023, 4:27pm UTC](https://discourse.julialang.org/t/in-closure-compile-away-a-step-in-a-calculation-internal-to-some-function-called-in-a-closure/105765 "2023-11-03T16:27:55Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![croberts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/croberts/32/9465_2.png) [@croberts](https://discourse.julialang.org/u/croberts)\
**Post date:** [November 3, 2023, 4:39pm UTC](https://discourse.julialang.org/t/in-closure-compile-away-a-step-in-a-calculation-internal-to-some-function-called-in-a-closure/105765/3 "2023-11-03T16:39:58Z")

</div>

I think my question is related to internals…

Core of the question is for a closure like:

```julia
X = something 
g = let x = X
    y -> f(x, y) 
end 

```

Is it currently possible for the Julia compiler, on first method call, to precalculate things within f(x,y) given X ? If so, how can this be achieved (e.g., is there some macro, like @inline, that would do this)? If not, is this something that could be feasibly accomplished in a later version of Julia?

---

_[View the full topic](https://discourse.julialang.org/t/in-closure-compile-away-a-step-in-a-calculation-internal-to-some-function-called-in-a-closure/105765)._
