Harmony object literals

Kam Kasravi kamkasravi at yahoo.com
Mon Jun 6 02:31:36 PDT 2011


In the object literals proposal the following 2 examples are given below:
var enhancedArrayProto = Array.prototype <| {
      do (func) {return this.foreach(func)},
      search (key {return this.indexOf(key) >= 0}
  };
  var myArray = enhancedArrayProto <| [0,1,2,3,4,5];
1. I believe search is missing a ')'
2. The first example is adding another prototype to Array.prototype, eg Array.prototype.prototype that contains do and search. Since this appends to the proto chain is it correct to say it's not possible to override methods using this operator? That is it's effect should only be additive?
3. Since the <| operator accepts an ObjectLiteral would it be extended to include classes?
  var enhancedArrayProto = Array.prototype <| class {
      public do (func) {return this.foreach(func)}
      public search (key) {return this.indexOf(key) >= 0}
  };
4. I'm not quite clear on what the myArray example does, is it adding a new prototype that provides initialization of some kind?  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110606/4ef4ef48/attachment.html>


More information about the es-discuss mailing list