Again on closures and type instability

The x -> inner(x,a) get evaluated (in the scope containing f) before it gets passed into outer. That is always the case, e.g.:

julia> a,b = 1,2
(1, 2)

julia> f(x) = x
f (generic function with 1 method)

julia> f(a + b)
3

there a+b gets evaluated first and then it’s passed to f. The same occurs in the case of the anonymous function and thus it binds a non-const global. This cannot be changed willy-nilly.

4 Likes