On Tue, May 29, 2012 at 9:45 AM, Mark S. Miller <[email protected]> wrote:
> 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 ":".
My and Nicholas' point is that normal developers *never see the
difference between these two*. Normal devs don't define setters on
Object.prototype, so the fact that "var obj = {foo:bar};" is different
from "var obj = {}; obj.foo = bar;" is *completely lost on them*.
Given that these two are identical to most devs, giving them distinct
syntaxes in the strawman is problematic. Further, and much more
importantly, [[DefineOwnProperty]] is *nearly never* the behavior that
a dev will actually want. Devs are *not* going to be replacing all
their Object.defineProperties() calls with monocle-mustache, because
*no one actually uses that function* in normal production, so there's
nothing to replace. Normal devs do a lot of property assigning,
though, and that's the use-case we're targetting with this.
If it's desperately important that we don't make "obj.{foo:bar}" do a
[[Put]], then it would be much better to simply not allow that syntax
*at all*. Make monocle-mustache solely use the "obj.{foo=bar}"
syntax, so that the other one is a syntax error. There's no good
reason to give devs the other type of functionality besides
completeness, and using it will almost always be a mistake on the
dev's part, I think.
Is the "setter on Object.prototype" the only observable difference
between the two?
~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss