Le 02/11/2012 12:20, Tom Van Cutsem a écrit :
> Hi Allen,
>
> 2012/11/1 Allen Wirfs-Brock <al...@wirfs-brock.com
> <mailto:al...@wirfs-brock.com>>
>
>     The above isn't how this will be expressed in the final spec.
>      Instead we will have
>
>     3) Let desc be the result of calling the [[GetOwnProperty]] internal
>     method of O with argument name.
>     4) Return the result of calling FromPropertyDescriptor(desc) (8.10.4).
>
>     And all Proxy objects will have a [[GetOwnProperty]] internal
>     methods that looks something like:
>
>     1) Let O be the object upon which this internal method was invoked.
>     2) Let desc be the result of calling TrapGetOwnProperty(O,name)
>     3) Return ToPropertyDescriptor(desc)
>
>     (I left out details of exception handling)
>
>
> Actually, while reviewing the spec, I realized that there is a good
> reason why the spec isn't currently specified this way (i.e. why
> the Proxy spec redefines Object.defineProperty and
> Object.getOwnPropertyDescriptor and does not just override
> [[DefineOwnProperty]] and [[GetOwnProperty]]) 
>
> It is to avoid the lossy conversion that otherwise occurs between the
> return value of [[GetOwnProperty]] and Object.getOwnPropertyDescriptor.
Just to be sure I fully understand: what is the loss exactly?
I see that custom property descriptor attributes would be stripped out
(because FromPropertyDescriptor outputs an object with 4 props mapping
1-to-1 to an accessor or data property descriptor).
Is there another loss?

If that's the only thing, redefining the property descriptor type to
accept any field would prevent that loss. Such a change would be more
aligned with the intention in the proxy spec of letting internal
operations manipulate custom attributes passed to Object.defineProperty.

I'm arguing in favor of switching to a script-usable type, but the
change I mention can occur in the spec-only type.

David
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to