On Dec 4, 2009, at 1:48 PM, Garrett Smith wrote:
Static Array and String Generics was an ES4 proposal[0], and is
implemented in Mozilla JavaScript 1.6[1].
What are the plans for including Array and String Generics in future
revision of ES?
I'm curious about this as well. We've had some requests to add these
to JavaScriptCore. I'd like to know if they were explicitly rejected
from standard ECMAScript, or might be considered for further
ECMAScript editions.
Would the ECMAScript standards community advise that we implement
these in WebKit or hold off?
- Maciej
There is no new syntax needed to support this. Scripts today can be
compatible by adding:-
if(!Array.slice) {
Array.slice= function( arrayLike, start, end ) {
return Array.prototype.slice.call( arrayLike,
start||0, end||arrayLike.length);
};
}
However, there is a remaining problem there: No guaranteed behavior
with Host object and Errors in IE. Example:
javascript:alert( [].slice.call( document.childNodes ) );
Error in IE8: "JScript Object Expected".
It would be best for IE to use Native object for Host objects. That
way, unwanted surprises like the above error should be done away with.
Array and String generics are useful for non-array objects.
The outcome of [].slice.call() should be determinable. It is up to
public-script coord to define what happens when a Host object is used
in an Array.
Brendan's 7-month-old message[2] asking for IE to comment on Array
generics with host object, should be proactively addressed.
There are open bugs for Webkit[3] and Chrome[4] for implementing Array
generics At the time that I filed the webkit bug, I was under the
impression that it was on its way to being standardized. I do not see
that happening.
Proposals:
1) ES Harmony standardize Static Array and String generics
2) The IE team use Native object for Host object collection
[0]http://wiki.ecmascript.org/doku.php?id=proposals:static_generics
[1]https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Working_with_Arrays
#Working_with_Array-like_objects
[2]https://mail.mozilla.org/pipermail/es-discuss/2009-May/009317.html
[3]https://bugs.webkit.org/show_bug.cgi?id=20261
[4]http://code.google.com/p/v8/issues/detail?id=308
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss