[Laszlo-dev] Proposal to tweak the behavior of attributes with a setter and an initial value
André Bargull
andre.bargull at udo.edu
Sat Apr 18 15:59:40 PDT 2009
>
> Pro:
>
> The setter code for cases like the above will not be erroneously
> skipped if the initial value is `null`.
>
I'm not really sure many users actually use identity comparison, I
assume they mostly use equality comparison. And if that assumption is
correct, it won't make any difference to use `null` instead of `undefined`.
> 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']`.
>
That'll be for sure annoying for many people. But it's not only the
> reference to undefined property 'foo'
warning which will appear if the initial value is changed to
`undefined`. Due to "implicit this" support and because it's impossible
to differentiate between a property which is set to `undefined` and an
`undefined` property in the swf8 runtime, also a debug-error will be
generated:
> reference to undefined variable 'foo'
A simple testcase:
<canvas debug="true">
<node>
<attribute name="foo" />
<handler name="oninit">
this.foo = void 0;
Debug.write(this.foo); // debug-warning: reference to undefined
property 'foo'
Debug.write(foo); // "implicit this" => debug-error: reference to
undefined variable 'foo'
</handler>
</node>
</canvas>
More information about the Laszlo-dev
mailing list