Hi Roman, Am 18.01.2009 um 20:22 schrieb Roman Schmid:
> You're right about all you said. However, since JavaScript is a > prototype-based language, you may sooner or later encounter modified > core language elements. Not only the qooxdoo framework does this... > there are numerous people who use prototype based extensions in > JavaScript. Yes, I know, and I think that's just as wrong as the qooxdoo prototype extensions :-) It's the same problem as with global functions: It's OK to use this stuff within your own application, but no framework should do it. > That being said, i think the point is valid that you should use > "for .. > in" on objects or "associative-arrays" and use the for-loop on numeric > arrays. This is what I, and probably most people, usually do. Otherwise, problems related to Array prototype extensions would crop up far more often. However, this stuff can get you into trouble on unexpected occasions. > Your example (sparse-array) would work just as well with "new > Object()" Except for the missing length property. Anyway, it was just an example. A more real-life problem occurs when different libraries add conflicting implementations of convenience methods to a prototype. > instead of "new Array()" and therefore we can come to the conclusion > that you should/could use "Array" for numeric, sequential Arrays and > "Object" for Maps, Associative-Arrays or whatever you like to call > them. > At least in the qooxdoo context it's a good idea to think that way. > > And as a side effect: This also helps you to distinguish between > numeric > and associative arrays (as a human, but also programmatically). I agree, but that's no reason to cause trouble when "for ... in" is used where something else would be better. qooxdoo takes care not to "pollute" the window object (except for the global "qx" namespace entry point, which cannot be avoided). So why pollute global prototype objects? Of course it's nice to have the additional methods, but they're not _that_ important. On the other hand, every once in a while someone stumbles over the modified Array prototype. Regards, Andreas J. ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ qooxdoo-devel mailing list qooxdoo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel