for n = 1:something_large
anon_func = x -> some_func(x, n) #Example anon func that needs to be defined within loop
i = findfirst(anon_func, A)
# some other code
end
Will a code pattern like this be creating a huge number of anonymous functions, and if so, are there any implications to this? Or will it create only one anonymous function at the code lowering point, and so there is basically nothing to worry about here? Any other potential pitfalls I should be aware of?
Ah! I’d seen the word “closure” pop up quite a lot around here but never quite worked out what it meant. The comments on that issue make things much clearer. Thanks for posting.