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]]?

Thanks,
Nicholas

On 5/28/2012 2:27 PM, Allen Wirfs-Brock wrote:
On May 28, 2012, at 1:23 PM, Erik Arvidsson wrote:

On Mon, May 28, 2012 at 12:19 PM, Nicholas C. Zakas
<[email protected]>  wrote:
Is it intentional that the first example uses colons between the property
and value while all others use the equals sign?
Yes this is intentional. We discussed this a bit at the F2F meeting
and we came up with the proposal to use = for [[Put]] and : for
[[DefineOwnProperty]]. Having a way to do [[Put]] is important because
it is common to want to trigger setters.
At added a clarification of this to the strawman....



For example:

class Monster {
  set health(value) {
    this.barColor = value<  10 ? 'red' : 'green';
    this._health = value;
  }
}

class GiantSpider extends Monster {
  constructor() {
    this.{
      health = 100
    }
  }
}

If you use .{health: 100} then the setter would not be invoked and the
object would not be in a correct state. This example might be a bit
contrived but using [[DefineOwnProperty]] is not the right answer in a
lot of cases.

This is especially important for setting values of DOM node properties which 
are generally implemented as accessor properties (ie, getters/setters).   That 
is why I used (thanks to dherman) a DOM element in most of the example that use 
+.

Allen




--
___________________________
Nicholas C. Zakas
http://www.nczonline.net

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

Reply via email to