Kevin Smith wrote:
Arbitrary prototype properties is surely to draw fire. It can be a
foot-gun and might conflict with instance properties in the future.
Foot gun: yes. I've shot myself in the foot with it. But I think it
can be addressed in a way that's footgun-proof. We're going to need
arbitrary prototype properties at some point.
Why? I mean, what built-in in ECMA-262 or a DOM spec needs non-method
data properties? Methods and accessors, yes. Constants go on the
constructor. I'm probably forgetting some bogus Java-like WebIDL binding
rule here...
Otherwise, we have to do something painful like:
if (this instanceof MyClass)
// construct it
else
return new MyClass(...args);
Even here, you can be spoofed by calling the constructor on an
already-constructed instance. It's hard to tell 'new' from invocation by
checking facts about |this|.
/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss