Originally Posted by aallkkaa
Which way does it work like?
|
It works more closely to A, but that's not the whole story. Look at this image:
Imagine that
a is a reference to the function you want to upvalue. By accessing the function through a variable, you're essentially just retrieving the
pointer to the memory where the function is stored (
b). When you upvalue a function, you're copying the contents of
a, that is to say the
memory address to your function, but not the actual function. The function you end up calling is the same, whether global or local in your scope.