Syntax Proposal: Allow Java-like Object Literals after constructor calls to set properties on created objects.
Allen.Wirfs-Brock at microsoft.com
Wed Jun 30 22:16:13 PDT 2010
While I really do think we made a poor choice, from a usability perspective, I've also come to the conclusion that it's really not a big problem. Most of the time and particularly for methods people really don't need to reconfigure or enumerate properties so the "high-integrity" attributes will still be satisfactory even if they are seemingly arbitrarily different.
The http://wiki.ecmascript.org/doku.php?id=strawman:obj_initialiser_meta proposal would allow an object literal to be used as an alternative to Object.create and would give you "normal" default attribute values.
From: es-discuss-bounces at mozilla.org [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Maciej Stachowiak
Sent: Wednesday, June 30, 2010 9:30 PM
To: Brendan Eich
Cc: Mark S. Miller; Jürg Lehni; Erik Arvidsson; es-discuss
Subject: Re: Syntax Proposal: Allow Java-like Object Literals after constructor calls to set properties on created objects.
On Jun 30, 2010, at 9:09 PM, Brendan Eich wrote:
On Jun 30, 2010, at 7:37 PM, Mark S. Miller wrote:
And you're right that attribute-property-missing -> undefined -> false has an effect here. If we had kept the ES3 negative names, we could have defaulted to false and Erik (I think) would not find Object.create a mistake -- but then the high-integrity-by-default fans would be put out. Those fans should speak up if they care to defend against the "mistake" charge.
Fine. Had it defaulted to low integrity, that would have been a mistake. Erik & I know we disagree on this.
Allen seems to agree with Erik. Is this just a matter of personal opinion? The point that I don't see you responding to is that the Object.create defaults are opposite from what every other way of binding a property in the language uses.
Ok, that could be answered by arguing that Object.create needs different defaults for different use-cases from those other property-creating forms.
I think the fact that you have to go out of your way to get normal defaults is a considerable inconvenience in many situations. I think Object.create would be easier to deploy if its defaults matched other ways of creating properties.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss