3 ms·
> Furthermore, most incarnations are not as powerful as MOPs in that they cannot redefine the language’s semantics. Yeah, but there is a reason for that... It
by cbsmith 12y ago
> Furthermore, most incarnations are not as powerful as MOPs in that they cannot redefine the language’s semantics.
Yeah, but there is a reason for that... It turns out to be less useful than you think, and altering language semantics in a meaningful way hampers the ability for an optimizer to make code execute efficiently (without the language's semantics, you really can't make assumptions).
> MOP needs to be severely restricted and for instance metaobjects cannot change at runtime..
True as far as it goes, but to the extent that they can change, the performance penalty is there because you can't resolve issues at compile time. There are a variety of tricks employed to get you a hybrid model, where you effectively have a JIT optimize after dynamic binding, but if you truly have mutating metaobjects, there is an undeniable cost that you can't get around (and the benefits really aren't that huge).
- smarr 12y agoWith generalized polymorphic inline caches (dispatch chains) you get that cost down to the dynamic check and the JIT compiler can remove all reflective overhead. So, in the end, you get a powerful MOP without reflective overhead.
- cbsmith 12y ago> With generalized polymorphic inline caches (dispatch chains) you get that cost down to the dynamic check and the JIT compiler can remove all reflective overhead. ...which results in a scenario no different in terms of overhead or expressiveness, than you'd have with a static MOP with runtime dispatch.
- smarr 12y agoI don't follow that logic. First, I don't know what you mean with static. That you can't change the metaobject associated with a baselevel object? That's a loss of expressiveness. And, what do you mean with runtime dispatch? Static and runtime dispatch combined? I am not sure I really know what you got in mind. With dispatch chains, the runtime dispatch is resolved at runtime and the JIT compiler can inline through it. But, you need that runtime information. A static compiler, like for OpenC++ can't usually do that.
- cbsmith 12y agoA simple example would be using templated classes and functions, all of which are navigated to from a virtual base class.