parent arguments
Jecel Assumpcao Jr.
jecel at merlintec.com
Tue Dec 13 00:23:14 UTC 2011
Here is a language feature which I thought we had discussed before, but
a quick search in this list's archives seems to indicate that we
haven't.
Officially Self has something that I am calling "parent arguments" in
this email. We tell that story that when a lookup finds a method as some
slot's value, we clone that method object transforming it into an
activation object by changing some of its slots. This includes adding a
special argument slot called "self" which is set to the receiver of the
message. This slot not only behaves like an argument, but it also
behaves like a parent (which is why it is indicated as :self* in our
drawings) and allows the method to access all the slots in the receiver.
There is a similar scheme to explain how blocks work, though the
:<lexicalParent>* slot doen't have a name that is visible through normal
message passing (in practice :self* doesn't either since "self" in the
source text is parsed into a special bytecode instead of as a send one).
Of course, this isn't at all how things are actually implemented. But it
is the story we tell about the language.
I was wondering if it wouldn't be interesting to have this as a real
feature of Self. Any object could have a parent argument slot and that
would get filled in with another object whenever it was cloned. So
w: myWrapper cloneWith: model.
would do essentially what we can now do with
w: myWrapper clone. w mParent: model.
This alternative supposes that myWrapper includes a parent data slot
called mParent. The difference is that this data slot can be reassigned
to some other object at any time while the proposed parent argument slot
can't be changed (not counting reflection) during that object's
lifetime. My idea is that this captures an interesting usage pattern
better than assignable parent slots.
-- Jecel
More information about the Self-interest
mailing list