I’m not arguing in favor of prototypes-as-classes, just against the assertion, 
below.

> There has to be a constructor function somewhere, somehow. The issue is what 
> name you invoke it by when calling vs. constructing. With 
> constructor-as-class it's the same name, the name of the abstraction denotes 
> the constructor. With prototype-as-class, the two diverge -- you call 
> C.constructor but you 'new C' (although you can spell out 'new C.constructor' 
> too if you like).


let o = new X(...);
- Constructor functions: X is the name of the construct that initializes the 
instance. Implicit/hidden: Specifying the prototype.
- Prototypes-as-classes: X is the name of the prototype of the new instance. 
Implicit/hidden: Invoking the method constructor().

Both have merit, I don’t see either one as being more elegant.

Purely subjectively, I find that the prototype is the thing that stays and 
lasts, while initialization only happens once. Obviously, constructor fans 
disagree with this assertion.

But if you like class literals syntactically then maybe we’re not even 
disagreeing here. Their clear advantage (over PaCs) is that they desugar to 
something that is perfectly compatible with current semantics.

-- 
Dr. Axel Rauschmayer

a...@rauschma.de
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com



_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to