Minor type confusion in proxies proposal?

Mark S. Miller erights at google.com
Fri Jul 1 18:29:11 PDT 2011


On Fri, Jul 1, 2011 at 2:55 PM, Brendan Eich <brendan at mozilla.com> wrote:

> On Jul 1, 2011, at 11:37 AM, Andreas Gal wrote:
>
> > In our implementation we are using a generic object. It has some
> overhead, and a specific internal "descriptor object" representation might
> be a bit faster, but such magic objects that don't allow expando properties
> are usually pretty surprising to programers. Most of the HTML5 DOM allows
> arbitrary expando properties. I think we should stick to that theme.
>
> IIRC Tom and Mark's http://traitsjs.org/ work relies on being able to
> extend property descriptors with .required and other ad-hoc ("expando")
> properties. This is important: it allows developers to blaze trails and
> tread paths that we later pave with standards.
>

These are present in the user visible descriptor objects, but traits.js does
not assume they are preserved in the internal descriptors. It can't assume
that, since trait.js works on current ES5 browsers whose internal
descriptors don't. Maybe Tom has thought about it, but we haven't discussed
how this change would effect traits.js. My guess it is would have a positive
effect. Tom?



>
> /be
>
> >
> > Andreas
> >
> > On Jul 1, 2011, at 5:54 AM, Andreas Rossberg wrote:
> >
> >> On 1 July 2011 12:12, Andreas Rossberg <rossberg at google.com> wrote:
> >>> I believe there is some "type" confusion in the proxy proposal spec
> >>> wrt property descriptors and their reification into attributes
> >>> objects.
> >>>
> >>> 1. In a note on the def of [[DefineOwnProperty]] for proxies, the
> proposal says:
> >>>
> >>> "The Desc argument to this trap is a property descriptor object
> >>> validated by ToPropertyDescriptor, except that it also retains any
> >>> non-standard attributes present in the original property descriptor
> >>> passed to Object.defineProperty. See the semantics of the modified
> >>> Object.defineProperty built-in, below."
> >>>
> >>> That seems fishy, since according to ES5 8.10:
> >>>
> >>> "Values of the Property Descriptor type are records composed of named
> >>> fields where each field‘s name is an attribute name and its value is a
> >>> corresponding attribute value as specified in 8.6.1."
> >>>
> >>> In particular, I take this to mean that property descriptors are not
> >>> objects (but abstract records), and that there cannot be any fields
> >>> whose name is not an attribute name. (In fact, in V8 we currently
> >>> encode property descriptors using objects, but the encoding is
> >>> different from the reified attributes object representation, and not
> >>> quite compatible with the idea of adding arbitrary other fields.)
> >>
> >> I forgot to say: step 5 of the definition invokes the defineProperty
> >> trap of the handler passing Desc as the second argument. But the
> >> handler expects a reified attributes object.
> >>
> >>> 2. In the modified definition of Object.defineProperty, the proposal
> >>> says in step 4.c:
> >>>
> >>> "Call the [[DefineOwnProperty]] internal method of O with arguments
> >>> name, descObj, and true."
> >>>
> >>> This is passing descObj, which in fact is _not_ a descriptor, but its
> >>> reification as an attributes object.
> >>>
> >>> /Andreas
> >>>
> >> _______________________________________________
> >> es-discuss mailing list
> >> es-discuss at mozilla.org
> >> https://mail.mozilla.org/listinfo/es-discuss
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110701/3ecba594/attachment.html>


More information about the es-discuss mailing list