> I wonder if the "only one semicolon" obsession is really worth it. Consider: 
> [...]

I agree. That’s a point I tried to make earlier: <| plus |super| mostly fix 
JavaScript inheritance (the shorthand for writing methods in an object literal 
is nice, too).

> As far as I'm concern, this is declarative enough:
> 1) <| provides the proper "super" (why the ".constructor"?) within the
> constructor body

It does make sense: There is a MyClass.prototype.contructor *method* and you do 
invoke the constructor as a method. So using super *without* "constructor" 
would be syntactic sugar. The syntactic sugar is more necessary if there isn’t 
ever an explicit "constructor" method. If there is (e.g. with class literals or 
prototype exemplars), then you don’t need the sugar, because it’s obvious.

> 2) <| also sets className.prototype.[[Prototype]] to superClass.prototype
> 3) this.{} to initialize instance properties
> 4) className.prototype.{} to set prototype properties
> 
> Because I write this in 2 instructions (i don't count constructor
> properties as I don't see why they're needed), I need to repeat
> "className". A dedicated class syntax would avoid this, I admit.

If you use class literals as a way to create modules, it is also a slight 
advantage. But ES.next has modules and possibly block lamdbas (as a replacement 
for IIFEs) that should help.

> On a side note. <| also sets className.[[Prototype]] to superClass (5).
> I still think this is a mistake and that two different operators should
> be defined. One operator for 1)+2) and the other for 5).

I am fine with how <| works, if you wanted to make a distinction, I would use 
one operator for setting a prototype and another one for “subclassing”. In 
subclassing, it makes sense that a “class” inherits the properties of its 
super-class.

-- 
Dr. Axel Rauschmayer
[email protected]

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to