<| ambiguity

Brendan Eich brendan at mozilla.com
Fri Dec 16 10:43:35 PST 2011

Please see http://wiki.ecmascript.org/doku.php?id=harmony:proto_operator -- the <| operator grammatically requires only literal object forms on its right.


----- Original Message -----
From: "Herby Vojčík" <herby at mailbox.sk>
To: es-discuss at mozilla.org
Sent: Friday, December 16, 2011 9:57:45 AM
Subject: <| ambiguity


I have read some articles on wiki.ecmascript.org as well as some post here.
It seems <| operator (which I only recently understood that it was probably 
meant to be the generalization arrow hollow top turned sideways :-) ) is 
used two ways.

As I understand, it was proposed (and I am with this semantics) so as
  proto <| obj
is roughly equivavlent with
  Object.create(proto)... // with elements of obj added

But I saw many uses like

  Car <| { ... }
  Car <| class Truck {...}
  Truck <| { ... }

where Car and Track are classes (constructor methods), not prototypes.

So which is the right semantics?

Thanks, Herby

P.S.: Maybe have two operators, <| for Object.extend semantics and <<|, <|| 
or <|= for the "raw instantiating" / subclassing one? 

es-discuss mailing list
es-discuss at mozilla.org

More information about the es-discuss mailing list