Enriched Descriptors, maybe ES7 ?

Allen Wirfs-Brock allen at wirfs-brock.com
Sun Mar 9 10:16:04 PDT 2014


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.  Proxies that support custom attributes might be an interest way toi experiment with some of these ideas.

Allen


On Mar 8, 2014, at 10:45 AM, Andrea Giammarchi wrote:

> Yesterday, after my DHTMLConf talk, some developer asked me to present/propose my idea about introducing **optional** types in an ES5 compatible way.
> 
> Here a quick overview of properties which aim is to guard types or methods signatures, compatible with overloads for both number of arguments, and acepted type per each argument and each "guarding group".
> 
> ```
> propertyName: {
>     // ES5
>     writable: true/false
>     enumerable: true/false
>     configurable: true/false
>     get: Function
>     set: Function
>     value: any
> 
>     // my complementary, non obtrusive, info
>     type: string(as typeof obj)|
>           Function(as instanceof)|
>           Object(as isPrototypeOf)
>     returns: type|[type1, type2, typeN]
>     arguments: [type]|[[type], [type]]
> }
> 
> ```
> 
> The return type can be different too, but I didn't forget to include the special type 'any' as white flag.
> 
> All types and what they mean are [better described here](https://github.com/WebReflection/define-strict-properties#types).
> 
> The most handy use case is probably `Object.defineProperties(Class.prototype, typedDescriptrs)` since each instance will be automatically guarded inheriting the guarded behavior.
> 
> As mentioned in [this project goals](https://github.com/WebReflection/define-strict-properties#objectcreateproto-typedproperties), an ideal/dream goal would be having tools capable of documenting/understanding typed properties such IDE or even "transpilers" and in a parallel universe JS engines capable to natively use such info per each descriptor when available and both speed up properties get/set operations guarding natively the specific type.
> 
> As example, this system made possible to implement a [StructType shim](https://github.com/WebReflection/define-strict-properties/blob/master/src/StructType.js#L57) in few lines of code.
> 
> I don't expect this to be discussed soon but I wanted to point at this library now that is just officially born, despite I've proposed something similar in my blog already in 2010, so that if there's any big gotcha/mistake/nonsense in it I am in time to fix/improve or change.
> 
> Thanks for your patience reading till the end and for any thoughts or hints that might come out.
> 
> Best Regards and happy JS Fest!
> 
> 
> 
> 
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140309/817b89e5/attachment.html>


More information about the es-discuss mailing list