Marcus Denker wrote:
What this means is that for someone who wants to implement a slot, you do not have to deal with bytecode at all.
This is very cool. Thanks Marcus. I look forward to playing with it.
Here is a simple Slot:
Slot subclass: #TestSlot instanceVariableNames: 'value' classVariableNames: '' category: 'Slot-Scopeâ
read: anObject ^ value
write: aValue to: anObject value := aValue
So this is a strange kind of Slot that stores the value in itself, which means it is shared between all objects as there is only one Slot meta object per class per slot. (not something you want to do in real world, but a nice demo)
Would a real world example for this be an atomic-counter? Such that the first time an instance reads its instance-slot, the slot-class-variable is incremented and stores the result in the instance-slot in an atomic way. (its a bit hard to work out the terminology to use in relation to that example) Just a random thought - should we now describe ':=' assignment operator as the 'slotting' operator, and the result is that the value has been 'slotted' ? /grin -ben