Block activation
Source (in traits number): signChar = (| s <- ©+© | < 0 ifTrue: [s: ©-©].··s) In -42 signChar, about to send ifTrue: In the block: |
Block activationBlock activation is similar to method activation, except that there is an extra stage. First, a block object is created at compile time. This has a parent* slot that refers to traits block, and a value method (appropriate to the number of arguments), with the block's code as the method body.When the expression containing a reference to this block is evaluated, the block is cloned, and the clone is given a hidden slot that refer's to the current activation object. When the block's method is activated (via a value message), the method is cloned and a hidden parent slot is added, containing a reference to the activation object saved in the previous step (not a self slot, as per methods). This allows the block to access the slots of enclosing block's and the outermost method (lexical scoping).
|