Io suggestion
Based on hash table vs. message-receivers and activatable slot, not value.
1. Every slot is activated on direct access. Non-activatable slot access raises exception.
2. x := y creates getter method(getSlot(“_x”)) and setter method(v, setSlot(“_x”, v); v).
3. x = y is parsed as x=(y) (i.e. message x= with argument y).
4. No ::=operator.
5. Method definition: obj setSlot(“add”, method(x, self + x))
5.1. Method definition macro: obj def add(x, self + x) (could be implemented in Io itself)
Pros:
- cleaner setters and hooks for setters;
- smaller syntax;
- uniform message dispatch: each message is processed by a method;
- safety: no need to use getSlot(“x”) for method arguments when activatable value could be passed (relevant to any abstract algorithms).
Cons:
- performance hit since local variable access should perform double hash table lookup; this could be optimized by storing hidden variables (_x) in a plain array.
What do you think?
