Semantics of method and block invocation

  • Methods are prototypes

  • When bound to a message, a method is cloned, arguments and self* are initialized.

Semantics of method and block invocation

A 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.
Note that when a method sends a message using the implicit form of self, the lookup first starts in the method itself (thereby making the argument, method locals and self accessible), then proceeds up the inheritance chain defined by self.

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.

[ Previous ] [ Index ] [ Next ]