The use of foo:bar in object literals and in JSON
causes [[DefineOwnProperty]] behavior, not [[Put]] behavior. Making
mustache's treatment of foo:bar inconsistent with object literals and with
JSON is a worse footgun. If you always want mustache-with-[[Put]], use "="
rather than ":".

On Tue, May 29, 2012 at 9:33 AM, Tab Atkins Jr. <[email protected]>wrote:

> On Tue, May 29, 2012 at 9:26 AM, Nicholas C. Zakas
> <[email protected]> wrote:
> > Thanks for the clarifications. I understand wanting to make the
> distinction
> > from an implementer point of view, I'm just not sure that developers make
> > the distinction between [[Put]] and [[DefineOwnProperty]] even using
> regular
> > object literals. Is there a reason that this:
> >
> > var obj = {};
> > obj.{
> >    name: "JS"
> > };
> >
> > Can't act the same as this:
> >
> > var obj = {};
> > obj.name = "JS";
> >
> > Wherein, if the property is already defined that acts as [[Put]] and
> > otherwise acts as [[DefineOwnProperty]]?
>
> Same thoughts here.  Regular devs (like me!) only see
> [[DefineOwnProperty]] when creating a literal, and then there's no
> observable distinction between these two in normal circumstances:
>
> var obj = { foo: bar }
>
> var obj = {};
> obj.foo = bar;
>
> I don't think it's worth optimizing for the [[DefineOwnProperty]]
> case.  We should just use the standard "foo:bar" syntax, and have it
> invoke [[Put]] behavior.
>
> As written, the strawman's attachment of the more natural "foo:bar"
> syntax for [[DefineOwnProperty]] is a footgun.
>
> ~TJ
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
    Cheers,
    --MarkM
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to