For function calls, that slot ends up holding the function being called. Since the slot has no name, the function body never accesses it. You can guess where this is going. For method calls, we can repurpose that slot to store the receiver. Slot zero will store the instance that this is bound to. In order to compile this expressions, the compiler simply needs to give the correct name to that local variable.
We want to do this only for methods. Function declarations don’t have a this. And, in fact, they must not declare a variable named “this”, so that if you write a this expression inside a function declaration which is itself inside a method, the this correctly resolves to the outer method’s receiver.
Why not use if (type == TYPE_METHOD) ... in the code above? Only methods will thus satisfy the condition. Such a test will clearly show that:
Consider the following excerpt:
Why not use
if (type == TYPE_METHOD) ...
in the code above? Only methods will thus satisfy the condition. Such a test will clearly show that: