I've asked because I use this pattern quite a lot Object.defineProperty({}, 'a', propValue(42))
function propValue(value) { // genericDescriptor define elsewhere genericDescriptor.value = value; return genericDescriptor; } obviously when it makes sense to reuse the descriptor. I define almost everything through this pattern that when I've seen an extra constructor around I've freaked out :D On Fri, Nov 2, 2012 at 9:35 AM, Allen Wirfs-Brock <al...@wirfs-brock.com>wrote: > > On Nov 2, 2012, at 9:29 AM, Andrea Giammarchi wrote: > > I would add ... am I the only one that does not create a new object per > each defined property ? I am recycling descriptor.value like hell, I wonder > if anyone else out there is doing the same. > > > Don't know what people are actually doing, but that usage mode was always > envisioned when we designed property descriptor objects. > > Allen > > > > > > > > > > On Fri, Nov 2, 2012 at 1:31 AM, Tom Van Cutsem <tomvc...@gmail.com> wrote: > >> 2012/11/1 David Bruant <bruan...@gmail.com> >> >>> The constructor I have proposed could have an equivalent initialization >>> syntax. >>> Object.defineProperty({}, 'a', PropDesc({value:42, writable:true})) >> >> >> I see the merit in your proposal as making the Object->PropDesc >> conversion explicit. However, I think it's too late for ES6: >> Object.defineProperty must continue to accept Objects as its third >> argument, and that's even shorter to write. So even if we would add such a >> PropDesc constructor, I don't think most developers (including myself) >> would adapt. >> >> Cheers, >> Tom >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> >> > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss