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

I probably should have posted this thread in ‘internals’ rather than ‘general usage’.

Is there a way to compile away a step in a calculation internal to some function called in a closure but without manually decomposing the function into its constituent calculations within the closure?

The Internals category is for the internals of the Julia implementation.

I think my question is related to internals…

Core of the question is for a closure like:

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?

I’ll answer in the original thread.

Thank you!!!