The class operator: a bridge between object and function exemplers

David Flanagan dflanagan at
Tue Nov 15 10:28:52 PST 2011

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).
So if the new operator will work correctly with both object and function 
exemplars, then what do we need the class operator for?  Given an object 
exemplar C, will 'new C()' and 'new class C()' do exactly the same 
thing? That seems bad.  Sorry if I'm being obtuse, but I can't see why 
we need both new semantics for 'new' and a 'class' operator.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list