Re: Enriched Descriptors, maybe ES7 ?
2014-03-09 21:05 GMT+01:00 Brendan Eich bren...@mozilla.com: Tom has experimented, IIRC. I don't know which implementations preserve extended property descriptor properties. As Allen mentioned earlier, proxies should receive in their defineProperty trap the full descriptor object as it was passed in by the user, including any custom attributes. The proxy is free to store it, and return it from any subsequent getOwnPropertyDescriptor trap (which is also specced so that it can return a non-normalized descriptor object with custom attributes). Normal (non-proxy) objects of course cannot store non-normalized descriptors, so any custom attributes are lost. Changing this would presumably have a big impact on implementations (which probably don't hang on to descriptor objects at all). If you want to experiment with custom attributes, my harmony-reflect shim supports this for proxies: var props = {}; var o = new Proxy({},{ defineProperty: function(target, name, desc) { props[name] = desc; return true; }, getOwnPropertyDescriptor: function(target, name) { return props[name]; } }); Object.defineProperty(o,p,{value:42, configurable:true, hello:true}) JSON.stringify(Object.getOwnPropertyDescriptor(o,p)) // prints // {configurable:true, // value:42, // writable:false, // enumerable:false, // hello:true } // - custom attribute preserved Using Firefox's built-in direct proxies implementation I get a TypeError. I'll investigate further and file a bug. Regards, Tom ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Enriched Descriptors, maybe ES7 ?
Le 10/03/2014 08:02, Tom Van Cutsem a écrit : Using Firefox's built-in direct proxies implementation I get a TypeError. I'll investigate further and file a bug. You already did https://bugzilla.mozilla.org/show_bug.cgi?id=601379 ;-) David ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Enriched Descriptors, maybe ES7 ?
Thanks Tom, I see what you mean but using proxies is a performance killer, while I am trying to propose something that theoretically could also give a performance boost. I am not proposing custom descriptor attributes here, I am proposing `type`, `arguments` (or `parameters`) and `returns` as specified/extra descriptor properties capable to bring typed properties to, maybe, ES7 My repository already does this and it works even copying objects, if this is done through `getOwnPropertyDescriptor` So, custom descriptor properties a part, would ES7 consider to implement types not only for `StructType` but also for runtime defined shapes so that `Object.defineProperty({}, 'num', {value: 123, writable: true, type: int32})` works same as my polyfill does already? Thanks On Mon, Mar 10, 2014 at 12:02 AM, Tom Van Cutsem tomvc...@gmail.com wrote: 2014-03-09 21:05 GMT+01:00 Brendan Eich bren...@mozilla.com: Tom has experimented, IIRC. I don't know which implementations preserve extended property descriptor properties. As Allen mentioned earlier, proxies should receive in their defineProperty trap the full descriptor object as it was passed in by the user, including any custom attributes. The proxy is free to store it, and return it from any subsequent getOwnPropertyDescriptor trap (which is also specced so that it can return a non-normalized descriptor object with custom attributes). Normal (non-proxy) objects of course cannot store non-normalized descriptors, so any custom attributes are lost. Changing this would presumably have a big impact on implementations (which probably don't hang on to descriptor objects at all). If you want to experiment with custom attributes, my harmony-reflect shim supports this for proxies: var props = {}; var o = new Proxy({},{ defineProperty: function(target, name, desc) { props[name] = desc; return true; }, getOwnPropertyDescriptor: function(target, name) { return props[name]; } }); Object.defineProperty(o,p,{value:42, configurable:true, hello:true}) JSON.stringify(Object.getOwnPropertyDescriptor(o,p)) // prints // {configurable:true, // value:42, // writable:false, // enumerable:false, // hello:true } // - custom attribute preserved Using Firefox's built-in direct proxies implementation I get a TypeError. I'll investigate further and file a bug. Regards, Tom ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Enriched Descriptors, maybe ES7 ?
2014-03-10 11:10 GMT+01:00 David Bruant bruan...@gmail.com: Using Firefox's built-in direct proxies implementation I get a TypeError. I'll investigate further and file a bug. You already did https://bugzilla.mozilla.org/show_bug.cgi?id=601379 ;-) Thanks for refreshing my memory on that one ;-) But that was actually not the bug that caused my earlier code snippet to fail. Instead it's this bug (already reported by Eddy Bruel): https://bugzilla.mozilla.org/show_bug.cgi?id=793210 Cheers, Tom ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss