On 11/14/11 3:01 PM, Allen Wirfs-Brock wrote:
On Nov 14, 2011, at 2:01 PM, Brendan Eich wrote:
On Nov 14, 2011, at 12:16 PM, Allen Wirfs-Brock wrote:
let Point = {
x:0,
y,0,
constructor(x,y} {
this.x=x;
this.y=y;
}
}.constructor; //<----------- note added property reference
let p = new Point(1,2); //new operator applied to a constructible
function
So can you spec operator new a bit? It tries [[Construct]] and if
missing, tries for a .constructor property that it calls on a fresh
instance of Object whose [[Prototype]] is the exemplar?
Yup, that's essentially the semantics. I'm going to write up the
object exemplar strawman which will cover this (and also instanceof).
I have a bad feeling about making 'new' work with both functions and
object exemplars. If we can have two different types of classes, we're
going to end up using typeof on our class objects to figure out what
kind of class they are. If I've got a value C from a library and I
think it is an object exemplar, but it is in fact a constructor
function, then 'class C' is going to return Function rather than C itself...
Object exemplars does not pave the cowpaths for classes: it creates a
new path and just smears out the concept of a class into something more
broad. I fear it will create confusion rather than " provide a terse
and declarative surface for those semantics so that programmer intent is
expressed instead of the underlying imperative machinery."
David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss