this boilerplate is error prone and prolix plus it cannot be optimized in core so it's also very slow.
With the introduction of classes, Symbols, and all ES6 new entries, I feel like the `for(var key in object)` loop is dead but developers have no way to clone objects in the right way and in one shot possibly optimized/optimizable in core. I understand it's very late but I wonder, with Rick help, if a "brutal" copy and paste of a very simple spec that feels natural as complement of the singular `Object.getOwnPropertyDescriptor(O, k)` would be considered ... I certainly don't want waste Rick time with this, neither yours, of course. So, in case ES6 is not an option, I wonder if we could have a slot in ES7 so that the polyfill could be adopted and developers life made easier. I really hope I didn't need in ES6 to write this: ```javascript var shallowCopy = Object.create( Object.getPrototypeOf(originalObject), Object.getOwnPropertyNames(originalObject).concat( Object.getOwnPropertySymbols(originalObject) ).reduce(function (descriptors, name) { descriptors[name] = Object.getOwnPropertyDescriptor( originalObject, name ); return descriptors; }, {}) ); ``` Thanks in advance for any outcome. On Tue, Mar 4, 2014 at 10:03 AM, Allen Wirfs-Brock <al...@wirfs-brock.com>wrote: > > On Mar 4, 2014, at 9:34 AM, Rick Waldron wrote: > > > > > On Tue, Mar 4, 2014 at 12:30 PM, Andrea Giammarchi < > andrea.giammar...@gmail.com> wrote: > >> Apparently this triggered an @rwaldron which seems to be super-effective >> >> In agenda for April's meeting. >> > > Yep: https://github.com/tc39/agendas/blob/master/2014/04.md > > Going to try, but it's so late in the game that I really can't promise > anything--I think it's simple enough that we can get away with it. I will > write up a proposed normative spec (likely based on Andrea's work) before I > present, I've found that's a pretty powerful way to make a case for late > additions ;) > > > I like this cloning idiom, but I don't see why we would consider this for > ES6, it isn't something that is critical or can't be implemented via ES > code. It would be much more appropriate to queue it up for the 2015 train. > > ES6: let's wrap this sucker up! > > Allen > > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss