Currently in LZX, you can create a (n anonymous) setter for your attribute by saying:

 <class name="base">
   <attribute name="foo" setter="this.foostate = frob(foo)" />
   ...
 </class>

Recently, the question came up: "how do you override that setter in a subclass, and how do you call the superclass setter from the override?" The following proposal addresses the question:

In a subclass, you override a setter by naming the same attribute and giving a new setter:

 <class name="sub" extends="base">
   <attribute name="foo" setter="..." />

If you want to invoke the superclass setter, you use `super.setAttribute('foo', ...`:

 <class name="sub" extends="base">
<attribute name="foo" setter="this.note('setting foo'); super.setAttribute('foo', foo)" />

For legibility, we would also like to introduce a new <setter> tag that allows you to write a setter more in the style of a method, for cases of complex setters. Hence the above could also be written:

<class name="sub" extends="base">
  <setter name="foo" args="newfoo">
    this.note('Setting foo to: ' + newfoo);
    super.setAttribute('foo', newfoo);
 </setter>

Comments?

Reply via email to