Property descriptors as ES6 Maps

David Bruant bruant.d at gmail.com
Wed Oct 31 05:05:55 PDT 2012


Le 31/10/2012 12:46, Andreas Rossberg a écrit :
> On 31 October 2012 10:40, David Bruant <bruant.d at gmail.com> wrote:
>> My bug was about making the use of objects [for property descriptors]
>> official in the spec internals... until I realized that ES6 has maps.
> Can you motivate why maps would be more adequate?
For "more adequate than object", I would say that they are not concerned
with pseudo-properties of JS-in-reality (__proto__, __defineGetter__,
...) which may make a difference in traps.

> Frankly, I completely disagree, because they would have a highly heterogeneous
> type.
Another idea is to define and expose a specific PropertyDescriptor type
(that will be manipulated by proxy traps). I would prefer that solution
actually, but I'm afraid backward compat may prevent that from happening.
It would be a great occasion to expose a bunch of PropertyDescriptor.*
functions to manipulate them.
For instance, with proxies, I've had to implement some algorithms to
merge descriptors (basically merge what I want to return with
invariant-enforceable parts of the target descriptor) and this code
belongs to the standard library, not application code.

David


More information about the es-discuss mailing list