Skip to content

Instantly share code, notes, and snippets.

@mildred
Created January 13, 2012 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mildred/1607388 to your computer and use it in GitHub Desktop.
Save mildred/1607388 to your computer and use it in GitHub Desktop.
Io with views
Let's imagine the object model if we want to implement Io in Parrot.
First, create a PMC IoObject that will represent an Io object. IoObject will contain a list of slots in the
object. There will also be a VTABLE function that will implement the behaviour when the object is activated
(called). Let's call it perform for the moment.
Let's imagine an object can have different set of slots. We call each of them views. We have the
introspection view, containing a perform2 method (different from the perform above which is a VTABLE
function), a isActivable method (true for methods, false for every other objects) and other introspection
related slots. We also have the default view for normal object operation. We can imagine having other
views. Views can be created at run-time.
Let's also imagine a syntax to get a slot (and perhaps perform it if it is activable) to get a slot of
particular view:
receiver view#slot(args)
--> if(receiver 0#isActivable) {
receiver 0#perform(view, slot, args)
}
--> VTABLE.perform(receiver, "0", "isActivable")
VTABLE.perform(receiver, "0", "perform", (view, slot, args)) if previous call is true
("1" is the default view, "0" is the raw or introspection view)
The basic syntax is still there:
receiver slot(args) ---> defaults to the default view,
Now, we can imagine a new kind of PMC (IoVariable) that will be a light proxy to the IoObjectPMC.
It will contain:
- an activation state (call object 0#isActivable, force activable, force non activable)
- a default view (default to "1")
- the object it points to
Its VTABLE.perform view argument will be optional, its basic job will be to:
- call object 0#isActivable (unless activation status forced)
- if the object is activable:
- call object.VTABLE.perform(receiver, view (provide default if necessary), slot, args)
- else:
- I screw up somewhere, there is a getSlot method to be called.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment