Extracting getters and setters

Michael O'Brien mob at mbedthis.com
Wed Feb 6 13:05:37 PST 2008


Question about getters and setters.  Can you assign a getter / setter to 
a var and invoke later?  i.e. can you extract a getter/setter method?

Consider:

class Shape {
    function get width(): int {
       return 1;
    }

    function set width(value: int): void {
    }

    /* Does this assign the getter or setter */
    var fun = width
}

var s: Shape = new Shape
s.fun()


ASC will extract the getter. But what should ES4 do? How can you extract 
the getter or the setter or both?

Under the hood, is the width getter/setter to be stored as one property 
or 2 and what is the property name?

Thanks

Michael O'Brien



More information about the Es4-discuss mailing list