Dan Sugalski wrote:

Okay, time to think about this.

We need the ability to layer PMCs. Nothing new, we need something of the sort for transparent read-only-ness and probably thread-safety (though we don't have to do it that way) and folks are going to want to do undoable custom vtable layering. While we don't *have* to let 'em do that, I'm inclined to if only because a good general-purpose mechanism will make things less error-prone overall.

So, then, the question is... how? I've got two schemes, neither of which I completely like, so I'm up for some discussion and more ideas.


The second scheme's major advantage (preserving the address of the logical (user-code-visible) PMC, so we don't have to run around updating symbol tables, or worse yet arrays, every time we wrap a PMC) seems IMHO to be pretty overwhelming.
AFAICT, it shouldn't really matter much that peeks at the logical PMC's internals may be incorrect (with one major caveat: if the _vtable_ functions try to use the PMC's address as an index into some data structure, things will go wrong since the PMC the base vtable functions get no longer has the same address as the logical PMC; if external things want to do so, that's fine though, since the logical PMC's address hasn't changed). After all, AIUI no one but the vtable functions is supposed to be poking inside the PMC, and the wrapper PMC (which happens to have the same address as the original PMC) will of course pass the new wrapped PMC down when it redispatches. (by MMD, I trust? Note that I think this scheme requires that the wrapper PMC types dispatch like the _base_ type (the type at the bottom of the layer stack, the original PMC) that they are wrapping (which means dynamic vtable and multimethod generation for each new wrapper/base type combo or some such so that the types work out correctl).)
This should even work correctly for things like Continuations as long as the opcodes don't try to be too smart. And I can definitely see (auto-)wrapping Subs as possibly being a reasonable (not too much code-duplication) way to implement privilige-domain-crossing checks for a secure Parrot.


-- BKS

Reply via email to