Currently, if you create an attribute with both a setter _and_ an initial value, the compiler will initially set the attribute to `null`, and then call the setter with the initial value. This is not actually right, but it lets setters get away with code like:

<attribute name="foo" value="null" />

<setter name="foo" args="newfoo">
  if (this.foo !== newfoo) {
    ...
  }
</setter>

People sometimes write this as an optimization, to avoid a complex setter if the value is not actually changing.

I propose that the 'initial initial' value of an attribute like this be `undefined`, rather than `null`, because it really has not been set yet. Furthermore, in an optimization like the above, the setter code will not be called on the `null` initial value of the attribute (because the compiler has already set it to `null`). This can lead to subtle bugs.

Pro:

The setter code for cases like the above will not be erroneously skipped if the initial value is `null`.

Con:

The setter code must take care checking the value of the attribute. Since it will initially be `undefined`, referencing it as `this.foo` will generate a warning in the swf8 runtime. To avoid the warning, the code must be re-written as `this['foo']`.

Comments?  Questions?

Reply via email to