Am 18.01.2009 um 20:42 schrieb Derrell Lipman:
On Sun, Jan 18, 2009 at 1:58 PM, Andreas Junghans <andreas.jungh...@stz-ida.de
> wrote:
> qooxdoo adds these functions to the Array prototype to provide a
> consistent interface between browsers. Although it seems to work to
> iterate an Array use for/in, it's not technically legal.
Sorry, I disagree. It's perfectly legal to iterate over an array with
for ... in. In fact, it can be very useful to do so if you're working
with sparse arrays (where only a few indices are ever assigned a
value). Please keep in mind that there's not a lot that separates a
JavaScript Array instance from any arbitrary object (which is always
an associative array in JavaScript):
Ok, you're right. Since all of my javascript programming these days
is with qooxdoo, I sometimes forget what's qooxdooish and what's
really javascript. Most of the time they jive. Here they don't.
It's also perfectly legal, however, as with any object, to add
additional methods to Array's prototype, and I don't believe that
the spec says whether these new methods should or shouldn't be
enumerated with for/in when using an array. (I would argue that they
shouldn't be, and that it's a bug in IE that they are, but that's a
separate issue.) Given that IE does behave differently than Firefox
in this area, I agree with you that qoxodoo should not add methods
to the Array prototype. I believe that you and I both argued that
long ago. At this point, however, it would be a huge backwards-
compatibility hit to remove them. I would recommend that they be
removed in 0.9 with migration scripts to correct the array method
usage to static function usage.
Maps (e.g. new Object) offers the same feature set as sparse arrays. A
(for ... in) loop may be used with all kinds of objects. Simply keep
in mind to use Arrays for classic array needs instead and Objects for
all other needs. It's quite simple to understand and really a basic
thing. There are quite a lot more complicated things in developing
cross-browser web applications (even with qooxdoo).
The issue with native prototype additions was discussed long time ago
(also on this list) and led to the current implementation. We just
added missing features of JavaScript 1.6, where the browsers do not
implement them. So all browsers at least have these features
afterwards. This is a good thing, because it means less problems when
developing cross browser web applications. We perfectly modeled these
methods like they should have been implemented by a JS-1.6 conforming
browser. There are no "additional methods". All utility methods are
placed in qx.lang.Array etc.
Finally, there is really no need to reopen this lenghtly discussion,
when there are no new points added to the list. These API changes
would not be worth the required time for the framework developers and
our user base.
Regards,
Sebastian
For qooxdoo use right now, if one wants to use for/in, the following
usage model might be appropriate:
var a = new Array();
var x = new Array();
a[23] = 42;
for (var i in a)
{
if (! isNaN(parseInt(i)))
{
x.push(i + ": " + a[i]);
}
}
alert(x.join('\n'));
I've tested that this works properly in both Firefox and IE.
Cheers,
Derrell
------------------------------------------------------------------------------
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
------------------------------------------------------------------------------
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