Re: Enriched Descriptors, maybe ES7 ?

2014-03-09 Thread Allen Wirfs-Brock
Note that ES6 proxies as specified permits Object.defineProperty/getOwnPropertyDescriptor to pass custom attributes in property descriptors and even passes them along (not sure if anybody has actually implemented this yet) wherever there is a internal get descriptor/set descriptor sequence.

Re: Enriched Descriptors, maybe ES7 ?

2014-03-09 Thread Andrea Giammarchi
my quick tests say no implementation does, all seem to create from the scratch a new object with only known/described descriptor properties. ```javascript Object.getOwnPropertyDescriptor( Object.defineProperty( {},'test',{value:123,type:'number'} ), 'test' ).type // undefined ``` I'd

Re: Enriched Descriptors, maybe ES7 ?

2014-03-09 Thread Brendan Eich
Andrea Giammarchi wrote: I'd love to know more about Tom experiments on this! With his polyfill on the original proxy implementation, now that I think about it. https://github.com/tvcutsem/harmony-reflect but originally http://es-lab.googlecode.com/svn/trunk/src/proxies/DirectProxies.js

Re: Enriched Descriptors, maybe ES7 ?

2014-03-09 Thread Andrea Giammarchi
Uhm .. that looks just like Proxy and descriptors with known specd properties ... might wait for Tom to know if he had anything to do with types and custom properties in descriptors too. Although my idea is more about types and less about proxies or descriptors themselves, these are fine as they

Re: Enriched Descriptors, maybe ES7 ?

2014-03-09 Thread Brendan Eich
Andrea Giammarchi wrote: Although my idea is more about types You are starting on the wrong foot there. Types mean something in CS. Best if you start with use-cases instead of abusing the term. What code do you want to write, and how exactly would it operate? /be

Re: Enriched Descriptors, maybe ES7 ?

2014-03-09 Thread Andrea Giammarchi
As written before, and explained in the project, I can write descriptors with optional extra properties such as: **type**, describing as string the typeof, as Function the expected instanceof, or as generic object as prototypeOf(expectedType) ```javascript var o = {}; Object.defineProperty(o,

Re: Enriched Descriptors, maybe ES7 ?

2014-03-09 Thread Andrea Giammarchi
about the first example, I forgot the writable for the num property so please read that as if I wrote: ```javascript var o = {}; Object.defineProperty(o, 'num', { writable: true, value: 0, type: 'number' }); ``` the library makes possible to create a partial shim of StructType in few lines

Re: Enriched Descriptors, maybe ES7 ?

2014-03-09 Thread Andrea Giammarchi
last link is [the test file]( https://github.com/WebReflection/define-strict-properties/blob/master/test/define-strict-properties.js) which better than examples in here describes what happens when the library is around, how ES5 descriptors can guard properties and methods within objects or