On Mon, Dec 7, 2009 at 12:42 PM, Allen Wirfs-Brock
<allen.wirfs-br...@microsoft.com> wrote:
> The "static generic" versions of these functions were discussed during the 
> development of ES5 but nobody advocated strongly for their inclusions.
>
> My personal opinion is that having what appears to be duplicate functions on 
> both Array and Array.prototype is a likely source of confusion for 
> unsophisticated programmers and largely unnecessary for more sophisticated 
> programmers who know how to use call.
>

Static arrray generics are already implemented in Firefox. I have not
any complaint about Array.slice being confusing.

But if you want to discuss personal opinions, mine is that "Unknown
Error" is the source of confusion and frustration.  That, and your top
posting is doing damage to the discussion.

> The inadmissibly of the array functions for host object is explicitly allowed 
> for by the ES3&5 specifications. However, I will make sure that those 
> responsible for the IE DOM are aware of the issue.
>

Yet still no response from the IE team here, or on the other thread
linked were Brendan asked for the IE Team to comment.

Back to opinions, now. What is your opinion on using generic method
with Host object? That's a very open ended question, so I'll explain a
more specific scenario:

A generic method is used with a host object as the thisArg. Should the
generic method perform the specified steps of the algorithm?

To be more specific, given anObject that supports [[Get]],
[[HasProperty]], and has a length property, where a program can
successfully executes the following code:

var x = anObject.length;
var h = anObject.childNodes;
var z = anObject["0"];

Then should the result of Array.prototype.slice.call( anObject ) be
predictable?

Take a look at Array.prototype.slice and, given an object with
properties "length=2", "0=object0", "1=object1", or, if JSON notiation
is clearer:

var object0 = {}, object1 = {},
anObject = {
  "length" : 2,
  "0", object0,
  "1", object1
};

- looking at Array.prototype.slice:-

1. Let A be a new array created as if by the expression new Array().
2. Call the [[Get]] method of this object with argument "length".
//  2

3. Call ToUint32(Result(2)).
// 2

4. Call ToInteger(start).
//  start is undefind - ToInteger = 0.

5. If Result(4) is negative, use max((Result(3)+ Result(4)), 0); else
use min(Result(4), Result(3)).
// Result 4 is 0, so use Min(0, 2) = 0

6. Let k be Result(5).
// k = 0

7. If end is undefined, use Result(3); else use ToInteger(end).
// end is undefined, Result 3 is 2.

8. If Result(7) is negative, use max((Result(3)+ Result(7)), 0); else
use min(Result(7), Result(3)).
// Min(2, 2) = 2.

9. Let n be 0.
10. If k is greater than or equal to Result(8), go to step 19.
// K is 0
[...]

11. Call ToString(k).
12. If this object has a property named by Result(11), go to step 13;
but if this object has no property named by Result(11), then go to
step 16.

13. Call ToString(n).
14. Call the [[Get]] method of this object with argument Result(11).

// Get the "0" property from anObject - object0.

15. Call the [[Put]] method of A with arguments Result(13) and Result(14).

// A["0"] = object0

16. Increase k by 1.
17. Increase n by 1.
18. Go to step 10.

// Continue populating A with properties from the thisArg.

19. Call the [[Put]] method of A with arguments "length" and n.
20. Return A.

In your opinion, should the result be predictable, as such? An why or why not?

Garrett
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to