On object extension

Mark S. Miller erights at google.com
Tue Nov 29 09:15:36 PST 2011

On Mon, Nov 28, 2011 at 9:51 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

> it is better to consistently reuse an existing policy than to make up a
> new policy for each new situation.

For me, this is the overriding consideration. ES5 defines two ways to set a
property: assignment and Object.defineProperty. Both have a complex set of
rules that need to be learned. Arguably some of these rules are
non-sensical[1], but they are now in stone. Given that we introduce new
syntax for setting properties, I strongly prefer that their semantics
simply be one of these two, even if suboptimal for the use case expected of
this new syntax, rather than invent yet a third set of rules for developers
to learn.

That said, because of the similarity of ".{" to object literals, I think
their semantics should simply be defined in the obvious way in terms of

[1] I have come to hate the rule that you can't override an inherited
non-writable data property by assignment. But I believe leaving this
mistake alone is better than the consequences of any attempt to fix it.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111129/05fe6577/attachment.html>

More information about the es-discuss mailing list