Gaetan de Menten schrieb: > On Feb 11, 2008 12:25 PM, Fabian Jakobs <[EMAIL PROTECTED]> wrote: > >>> Does anybody know if there is a better way than: >>> var statics = qx.Class.getByName(this.classname) >>> >>> to access the static members/class variables of the "current" (most >>> specialized) class from one of its parent class? >>> >>> >> I think this is the best way to do it. >> > > >>> this.self(arguments) returns me those of the parent class. >>> >>> >> This method will return the class, the method was originally defined in. >> I still think this is a good default behavior. The method should >> reference always exactly the same static variable, no matter in which >> context the method gets called. >> >>> Shouldn't something like this be the default behavior for >>> this.self(arguments) (*)? This behavior is quite standard for class >>> variables in OO languages. >>> >>> >> If you want this behavior you can always use member variables. >> > > Member variables is both not what I need (for example if you want to > count the number of instances), and possibly not efficient (for > constants) to be duplicated in every instance instead of being stored > globally at the class level. > The first example is a good point. This would be much easier with your suggestion. The second one is no problem because of the nature of prototype based inheritance. All members are stored in the class prototype and as long as you don't change the value on an instance the value will be shared by all instances. So there is no efficiency problem.
> >> Why >> should it be possible to override static/class variables in sub classes? >> Then they would not be truely static. >> > > I don't see why you wouldn't want class variables to be overrideable > in subclasses. This is how it works in most of the several OO langages > I've used. Try it in Python (as you seem to be using it quite a lot), > and see what I mean. For the static part, I honestly don't remember if > those are overrideable, since I'm using mostly python these days. > I think I'm spoiled by JavaScript :-) The main reason is that JS has no natural way to do so. If we wanted to have that, we had to do the lookup ourselves and, which would be to expensive in most cases. > >>> (*) In practice, and given Qooxdoo current way of doing things, you >>> can't simply do that, I think. I think you'd have to add a method to >>> get one "static attribute" back, which would do that and a recursive >>> lookup in the parent class if the attribute is not found in the >>> "specialized" class. >>> >>> > > -- Fabian Jakobs JavaScript Framework Developer 1&1 Internet AG Brauerstraße 48 76135 Karlsruhe Amtsgericht Montabaur HRB 6484 Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Andreas Gauger, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Achim Weiss Aufsichtsratsvorsitzender: Michael Scheeren ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ qooxdoo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
