Semantics of method and block invocation
|
Semantics of method and block invocationA method should be thought of as a prototype for the corresponding method activation. When a message is bound to a method:
1. The method is cloned. 2. The clone's argument slots are initialized with arguments from the message. 3. A slot, self*, is added to the cloned method and bound to the receiver of the message. This ensures that subsequent messages to self are correctly bound. Example:
send foo: 3 to (| x = 42. foo: = (| :arg. local | local: arg+x. local*2 ) |)The state of the activation after the assignment to local is shown overleaf.
|