Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-07 Thread Brendan Eich
Tom Van Cutsem wrote: Given that most of the functions that use [[OwnPropertyKeys]] need to either construct an array anyway, or want reliable results, I wonder whether we shouldn't just change [[OwnPropertyKeys]] to include the checks and return an array instead of an iterable. That way we avo

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-07 Thread C. Scott Ananian
I was also a bit puzzled by the iterator return value. I expected that it would handle mutation (adding new properties) during traveral the way that the `Map` and `Set` iterators do. I was surprised to see that all the users turned the iterator into an array; none seemed to handle concurrent muta

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-07 Thread Tom Van Cutsem
2014-03-07 0:51 GMT+01:00 C. Scott Ananian : > On Thu, Mar 6, 2014 at 6:31 PM, André Bargull > wrote: > > On 3/6/2014 11:35 PM, Andrea Giammarchi wrote: > > The proposed [[GetOwnPropertyNames]] internal method is supposed to be a > > more restrictive version of [[OwnPropertyKeys]] to ensure Proxy

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-06 Thread C. Scott Ananian
On Thu, Mar 6, 2014 at 6:31 PM, André Bargull wrote: > On 3/6/2014 11:35 PM, Andrea Giammarchi wrote: > The proposed [[GetOwnPropertyNames]] internal method is supposed to be a > more restrictive version of [[OwnPropertyKeys]] to ensure Proxy objects > don't lie about their properties. [[SafeOwnP

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-06 Thread Andrea Giammarchi
got it, thanks again. On Thu, Mar 6, 2014 at 3:31 PM, André Bargull wrote: > On 3/6/2014 11:35 PM, Andrea Giammarchi wrote: > >> autocomplete misspelled Andre' , apologies >> >> > No worries! :-) > > > >> On Thu, Mar 6, 2014 at 2:34 PM, Andrea Giammarchi >> mailto:andrea.giammar...@gmail.com>>

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-06 Thread André Bargull
On 3/6/2014 11:35 PM, Andrea Giammarchi wrote: autocomplete misspelled Andre' , apologies No worries! :-) On Thu, Mar 6, 2014 at 2:34 PM, Andrea Giammarchi mailto:andrea.giammar...@gmail.com>> wrote: Thanks Andrew, I wonder if I should update the proposed spec somehow, but I thoug

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-06 Thread André Bargull
On 3/6/2014 10:24 PM, Brendan Eich wrote: André Bargull March 6, 2014 at 1:21 PM I would rephrase into this: if you need a getOwnPropertyNames trap, you might need for consistency a getOwnPropertySymbols independently from getOwnPropertyDescriptors since these met

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-06 Thread Andrea Giammarchi
autocomplete misspelled Andre' , apologies On Thu, Mar 6, 2014 at 2:34 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > Thanks Andrew, I wonder if I should update the proposed spec somehow, but > I thought as it is combines both Names and Symbols as abstract. > > Please let me know

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-06 Thread Andrea Giammarchi
Thanks Andrew, I wonder if I should update the proposed spec somehow, but I thought as it is combines both Names and Symbols as abstract. Please let me know and I'll update. Best Regards On Thu, Mar 6, 2014 at 1:21 PM, André Bargull wrote: > I would rephrase into this: > > if you need a getO

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-06 Thread Brendan Eich
André Bargull March 6, 2014 at 1:21 PM I would rephrase into this: if you need a getOwnPropertyNames trap, you might need for consistency a getOwnPropertySymbols independently from getOwnPropertyDescriptors since these methods are already available. While it shar

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-06 Thread André Bargull
I would rephrase into this: if you need a getOwnPropertyNames trap, you might need for consistency a getOwnPropertySymbols independently from getOwnPropertyDescriptors since these methods are already available. While it shares the same name with Object.getOwnPropertyNames(), this getOwnPropert

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-06 Thread Andrea Giammarchi
I would rephrase into this: if you need a getOwnPropertyNames trap, you might need for consistency a getOwnPropertySymbols independently from getOwnPropertyDescriptors since these methods are already available. I also would like to add a couple of links to support the fact getOwnPropertyDescripto

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-06 Thread C. Scott Ananian
If you use a getOwnPropertyNames trap, then you also need a getOwnPropertySymbols trap to implement getOwnPropertyDescriptors. --scott On Thu, Mar 6, 2014 at 2:16 AM, Tom Van Cutsem wrote: > 2014-03-05 20:11 GMT+01:00 C. Scott Ananian : >> >> On Wed, Mar 5, 2014 at 1:39 PM, Tom Van Cutsem wrote

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-05 Thread Tom Van Cutsem
2014-03-05 20:11 GMT+01:00 C. Scott Ananian : > On Wed, Mar 5, 2014 at 1:39 PM, Tom Van Cutsem wrote: > > Object.getOwnPropertyDescriptors(proxy) would trigger the > > getOwnPropertyNames trap, followed by calls to the > getOwnPropertyDescriptor > > trap for each individual property. > > [[OwnPro

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-05 Thread Andrea Giammarchi
Thanks for clarification Tom, I've also added the main two _features_ this method in the first gist I've posted but here a quick recap: ```javascript // for shallow object copy var shallowCopy = Object.create( Object.getPrototypeOf(origin), Object.getOwnPropertyDescriptors(origin) ); // for

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-05 Thread C. Scott Ananian
On Wed, Mar 5, 2014 at 1:39 PM, Tom Van Cutsem wrote: > Object.getOwnPropertyDescriptors(proxy) would trigger the > getOwnPropertyNames trap, followed by calls to the getOwnPropertyDescriptor > trap for each individual property. [[OwnPropertyKeys]], `ownKeys` trap. --scott _

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-05 Thread Tom Van Cutsem
Object.getOwnPropertyDescriptors(obj) makes sense to me. As noted somewhere upstream, it's symmetrical to Object.defineProperties. When I designed traits.js, which was heavily based on property descriptors, I even added it to the library's public API, under the slightly shorter name Object.getOwnP

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Andrea Giammarchi
You are right, I've realized it after posting ... `Object.assign(target, source)` via `Get` and `Put` is basically the equivalent of a classic `for/in` with `hasOwnProperty` check ... well, once again, in ES6 `Object.getOwnPropertyDescriptors(O)` seems to be a solution for other cases too (shallow

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Claude Pache
> Le 5 mars 2014 à 00:18, Andrea Giammarchi a > écrit : > > > Also please note that this proposal simplifies [Object.assign(target, > source)](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) > too since latter one is basically: > > ```javascript > Object.defineProp

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Andrea Giammarchi
"thing" ... no "things", just this one ... pliz :-) Also please note that this proposal simplifies [Object.assign(target, source)]( https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) too since latter one is basically: ```javascript Object.defineProperties( target,

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Rick Waldron
On Tue, Mar 4, 2014 at 2:40 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > Allen, as developer, being unable to `shallow-copy` in JavaScript for > other *N* years is actually critical. > > Luckily it's not so difficult to polyfill but if you have Rick presenting > [something like th

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Andrea Giammarchi
Allen, as developer, being unable to `shallow-copy` in JavaScript for other *N* years is actually critical. Luckily it's not so difficult to polyfill but if you have Rick presenting [something like this]( https://gist.github.com/WebReflection/9353781#objectgetownpropertydescriptorso) I really hope

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Allen Wirfs-Brock
On Mar 4, 2014, at 10:17 AM, Rick Waldron wrote: >> > > 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: l

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Andrea Giammarchi
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 s

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Rick Waldron
On Tue, Mar 4, 2014 at 1:03 PM, Allen Wirfs-Brock 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

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Andrea Giammarchi
und that's a pretty powerful way to make a case for late >>> additions ;) >>> >>> >>> Rick >>> >>> >>>> >>>> Thanks >>>> >>>> Sent from my Windows Phone >>>> -

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Allen Wirfs-Brock
On Mar 4, 2014, at 9:34 AM, Rick Waldron wrote: > > > > On Tue, Mar 4, 2014 at 12:30 PM, Andrea Giammarchi > 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

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Rick Waldron
On Tue, Mar 4, 2014 at 12:48 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > yes, because `Object.getOwnPropertyDescriptor(O, k)` accepts both > `propertyName` and `Symbol` as second argument. The plural, and to be > consistent with the shallowCopy example, should return a list of bo

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Andrea Giammarchi
on Andrea's work) before I >> present, I've found that's a pretty powerful way to make a case for late >> additions ;) >> >> >> Rick >> >> >>> >>> Thanks >>> >>> Sent from my Windows Phone >>> -

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Rick Waldron
; > >> >> Thanks >> >> Sent from my Windows Phone >> ------ >> From: C. Scott Ananian >> Sent: 3/4/2014 6:16 >> To: Andrea Giammarchi >> Cc: es-discuss@mozilla.org list >> Subject: Re: Object.getOwnPropertyDesc

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Rick Waldron
make a case for late additions ;) Rick > > Thanks > > Sent from my Windows Phone > -- > From: C. Scott Ananian > Sent: 3/4/2014 6:16 > To: Andrea Giammarchi > Cc: es-discuss@mozilla.org list > Subject: Re: Object.getOwnPropertyDescriptors(O)

RE: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-04 Thread Andrea Giammarchi
t: Re: Object.getOwnPropertyDescriptors(O) ? // plural Have you filed a bugzilla ticket for this? That seems the best way to ensure it will get discussed at the next TC39 meeting and resolved one way or the other. --scott On Mar 3, 2014 8:44 PM, "Andrea Giammarchi" wrote: > up ? > > &g

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-03 Thread Andrea Giammarchi
up ? On Sun, Mar 2, 2014 at 5:43 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > Brandon I take your answer as +1, thanks. > > I've also "gisted" a possible/basic polyfill here: > https://gist.github.com/WebReflection/9317065 > > Cheers > > > On Sun, Mar 2, 2014 at 5:16 PM, Andrea

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-02 Thread Andrea Giammarchi
Brandon I take your answer as +1, thanks. I've also "gisted" a possible/basic polyfill here: https://gist.github.com/WebReflection/9317065 Cheers On Sun, Mar 2, 2014 at 5:16 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > actually, since `Object.getOwnPropertyDescriptor` accepts

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-02 Thread Andrea Giammarchi
actually, since `Object.getOwnPropertyDescriptor` accepts `Symbols` too as second argument, the equivalent with current ES6 would be even more prolix than that ```javascript var shallowCopy = Object.create( Object.getPrototypeOf(originalObject), Object.getOwnPropertyNames(originalObject).conc

Re: Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-02 Thread Brandon Benvie
Further rational: * Symmetry with defineProperty/defineProperties. * One of the benefits of defineProperties (and create) is that they handle errors such that the failure of any individual property doesn't necessarily fail all the remaining ones. It is, of course, possible for a developer to de

Object.getOwnPropertyDescriptors(O) ? // plural

2014-03-02 Thread Andrea Giammarchi
I wonder if by any chance this could sneak into ES6 ... we have only singular version here: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.getownpropertydescriptor **rationale** The easiest way to create a shallow copy of a generic object could be: ```javascript var shallowCopy