prototype for operator proposal for review

Luke Hoban lukeh at microsoft.com
Tue May 17 21:49:44 PDT 2011


If there were a more usable library variant of Object.create instead, it seems the new syntax here would not be as necessary.

Instead of:
  var  o = myProto <| {
       a: 0,
       b: function () {}
  }

You could do:
  var  o = Object.make(myProto, {
       a: 0,
       b: function () {}
  })

A few more characters, but still addresses the major issue preventing wider Object.create usage (the use of property descriptors).  A library solution also keeps the benefit of not needing new syntax, and being available to text/javascript.  As noted in the strawman, similar functions on Array and Function could support the other scenarios described in the proposal.

It seems the syntax is perhaps aiming to avoid needing to allocate an intermediate object - but I imagine engines could potentially do that for Object.make and friends as well if it was important for performance?

Luke

From: es-discuss-bounces at mozilla.org [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Allen Wirfs-Brock
Sent: Tuesday, May 17, 2011 7:50 PM
To: es-discuss at mozilla.org
Subject: prototype for operator proposal for review

We had so much fun with feedback on my Unicode proposal I just have open another one up for list feed back:

An updated version of the "prototype for" (formerly proto) operator proposal is at http://wiki.ecmascript.org/doku.php?id=strawman:proto_operator

Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110518/7daca69e/attachment.html>


More information about the es-discuss mailing list