Questions about setters
Lars Hansen
lhansen at adobe.com
Fri Jul 25 01:15:25 PDT 2008
> -----Original Message-----
> From: es4-discuss-bounces at mozilla.org [mailto:es4-discuss-
> bounces at mozilla.org] On Behalf Of P T Withington
> Sent: 24. juli 2008 22:30
> To: es4-discuss at mozilla.org es4-discuss
> Subject: Questions about setters
>
> Can I override a setter?
That's the intent.
> Can I call the setter I override using super? How exactly?
Not sure, but there might be something in the super syntax (eg, "super.x
= 10") that
would do this. Hasn't been spec'd yet. Not sure what AS3 does.
> > class foo {
> > var barstate;
> > function set bar (value) { barstate = bar }
> > function get bar () { return barstate }
> > }
> >
> > class annotatedFoo {
> > override function set bar (value) {
> > note('setting bar');
> > // how do I call my super?
> > super['set bar'](value);
> > }
> > override function get bar () {
> > note('getting bar');
> > // how do I call my super?
> > return super['get bar']();
> > }
> > }
>
> Can `super` by itself mean "call next method"? That would seem like a
> useful shortcut, and avoid the question of how you call a method with
> a space in its name.
I agree that would be convenient.
--lars
More information about the Es4-discuss
mailing list