.newApply() ?
On Nov 10, 2007, at 5:17 PM, Garrett Smith wrote:
I know it's too late for a proposal, but I keep wanting a couple of things for AOP stuff.
One is a newApply
Creational = { getByNode : function(el){ if(!this.hasOwnProperty("instances")) this.instances = {}; return this.instances.hasOwnProperty(el.id) && this.instances [el.id] || (this.instances[el.id] = this.new.apply(arguments)); // <--
Fictitious syntax. } }function Widget(el, dir){
}
Wiget.getByNode = Creational.getByNode; // Borrow the getByNode method
So that way, I can have a Widget based on a node, yet still pass varargs to the constructor.
Got your back here ;-). Narcissus (lxr.mozilla.org/mozilla
source/js/narcissus/) wants this too, and it's going to end up
falling out of the reflection APIs:
reflect::typeOf(this).reflect::construct(arguments)
or of course:
{ use namespace reflect; . . . typeOf(this).constructo(arguments) }
in your example. The doku.php?
id=proposals:meta_objects proposal is out of date, it uses iterators
for the type and value parameters, but IIRC we have agreement to
satisfy your use-case. See bugs.ecmascript.org/ticket/232.
On Nov 11, 2007 1:34 AM, Brendan Eich <brendan at mozilla.org> wrote: [snip]
Got your back here ;-). Narcissus (lxr.mozilla.org/mozilla source/js/narcissus/) wants this too, and it's going to end up falling out of the reflection APIs:
reflect::typeOf(this).reflect::construct(arguments)
or of course:
{ use namespace reflect; . . . typeOf(this).constructo(arguments) }
+1 eden want this too :) edenrr.googlecode.com/svn/trunk/as3/src/buRRRn/eden/ECMAScript.as
in there I got a scanFunction() that need to be able to switch between a simple function call with arguments or a contructor call with arguments, at runtime
so 2 follow up questions about the reflect namespace
is something as
var str = "some.thing::MyClass"; var c:Class = getObjectFromString( str ); //maybe a use of eval here ? var instance:* = eflect::typeOf( c ).reflect::construct(arguments);
can work ?
]> in your example. The doku.php?
id=proposals:meta_objects proposal is out of date, it uses iterators for the type and value parameters, but IIRC we have agreement to satisfy your use-case. See bugs.ecmascript.org/ticket/232.
and then the second question, is the meta objects and reflect namespace are optionnal ?
some months ago I remember they were but now in the wiki page I see "This proposal is to amend the spec with a normative set of meta-objects which must be present in any program and accessible at runtime."
but as the page is out of date, just wondering
I know it's too late for a proposal, but I keep wanting a couple of things for AOP stuff.
One is a newApply
Creational = { getByNode : function(el){ if(!this.hasOwnProperty("instances")) this.instances = {}; return this.instances.hasOwnProperty(el.id) && this.instances[el.id] || (this.instances[el.id] = this.new.apply(arguments)); // <-- Fictitious syntax. } }
function Widget(el, dir){
}
Wiget.getByNode = Creational.getByNode; // Borrow the getByNode method
So that way, I can have a Widget based on a node, yet still pass varargs to the constructor.
Garrett