Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by vincentpiel

The get / set syntax is very usefull, it works like this :

var tellMe = {
get message() { return this._message;},
set message (val) { this._message=' still no, even if you say '+val; }
_message :"no",
};
alert (tellMe.message); // -- >> "no"
tellMe.message = "yes";
alert (tellMe.message); // -- >> "still no, even if you say yes"

so it is a handy (and not uncommon in other languages) thing.

BUT ... if i use get / set in a ig.Class, for instance when extending an ig.Class,
i get :
alert (tellMeClass.message); // -- >> "no"
tellMeClass.message = "yes";
alert (tellMeClass.message); // -- >> "yes"
so it is broken.
Notice that the getter stills works, but the setter does not, so first time you
write to the property the getter is destroyed.
So right now you might only do readonly properties.

(Rq : i found that link usefull : http://ejohn.org/blog/javascript-getters-and-setters/ )

1 decade ago by vincentpiel

(another usefull link here : http://stackoverflow.com/questions/6039676/copying-javascript-getters-setters-to-another-prototype-object )
Page 1 of 1
« first « previous next › last »