Property descriptors as ES6 Maps

Axel Rauschmayer axel at rauschma.de
Thu Nov 1 02:45:14 PDT 2012


(Assuming that I understand the issue.)

The "object to map" refactoring matters whenever you don't know the keys in advance. If you do, as is the case with property descriptors, objects are fine. Then they are more like records than like maps.

Axel

[[[Sent from a mobile device. Please forgive brevity and typos.]]]

Dr. Axel Rauschmayer
axel at rauschma.de
Home: http://rauschma.de
Blog: http://2ality.com

On 01.11.2012, at 10:37, Tom Van Cutsem <tomvc.be at gmail.com> wrote:

> Hi,
> 
> David, I think I see where you are going: property descriptors are basically "bags" of key/value properties, and maps are a more direct representation of this concept than objects.
> 
> On the other hand, as so carefully explained by Allen, there currently isn't really an issue with the mapping between property descriptors and objects: at all the boundary points, we make sure to properly convert descriptors into well-behaved objects and vice versa.
> 
> As you point out yourself, making the change from objects to maps implies a bunch of backwards compat. issues. My position is that doing the object->map refactoring at this stage would entail a lot of work for very little gain.
> 
> Finally, remember that property descriptors-as-objects really leverage the object literal notation (i.e. I can create a property descriptor by just writing "{value:42,writable:true}". I don't think there is a corresponding sweet syntax for literal maps? In any case, Object.defineProperty will need to continue accepting such literal objects as its third argument, so why not keep the story simple and not widen the type to object | map.


More information about the es-discuss mailing list