InterType Declarations, Cross-Cutting - how to in ES4?
Garrett Smith
dhtmlkitchen at gmail.com
Sun Nov 11 18:03:35 PST 2007
InterType Declarations
InterType Declarations are a useful Iand popular) way of adding
functionality to an object, usually to the prototype of a constructor.
Lets say I have a class Widget that I want to borrow from:
class Widget {
private function Widget(){}
static {
getByNode : function():Widget { }
}
prototype {
var isBeingDragged : false,
valueOf : function(){ },
toString : function():String { },
}
function moveTo(x, y){ }
}
Class Orangutan {} // Borrows from Widget
In ES3, I can use a crossCut function:
crossCut : function(receiver, supplier, propsArray, borrowFilter) { }
What is the ES4 way to introspect or modify or a class?
I want to provide beforeAdvice to the static Widget.getInstance.
For other Orangutan, I want to provide afterAdvice to the constructor
(add to pool) (or is this aroundAdvice?).
I want to borrow the prototype properties of Widget, to Orangutan (for
default read access)
I want to borrow the static methods.
Is this done through the traits?
Can I modify a sealed class? My understanding is that a sealed class'
instances can't have dynamic props. what about the class itself?
Also, is there a way to get the function name from an anonymous
function via the identifier it's bound with, or do I have to type:
getByNode: function getByNode():Widget{ }. I find the repetition
annoying to my hands and eyes. I want access to the function name
without having to do this.
--
Programming is a collaborative art.
More information about the Es4-discuss
mailing list