getter & setter for private objects
memolus at googlemail.com
memolus at googlemail.com
Sat Nov 14 05:30:33 PST 2009
manager = function(object) {
this.init.apply(this, arguments);
}
manager.prototype = new function() {
/* Private Properties */
var gui;
var obj;
/* Constructor */
this.init = function(object) {
gui = new Gui();
obj = object;
}
/* Property with both accessor and mutator */
this.__defineGetter__("modus", function() {
[..]
});
this.__defineSetter__("modus", function(modus) {
[..]
});
/* Privileged public method which affords access to private properties */
this.getGui = function() {
return gui;
}
}
Currently I'm able to set accessor and mutator for properties of "this", but not
on the lexical scope chain. I want e.g. "modus" to be private.
Anyway I hope you get what I mean. It's an
evolutionary step to class support. Other programming languages
support
private int foo {
get { [..] }
set { [..] }
}
More information about the es-discuss
mailing list