>> Moving functions out of a loop is not as simple as you think: the loop may not be visible at all and come from an invisible outer scope
If you are not depending on an upvalue you can always return a reference to function that is defined outside the scope that's returning it and thus return a the same version every time?