New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is Note 2 from Array.prototype.slice meaningful? #219

Closed
littledan opened this Issue Nov 25, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@littledan
Member

littledan commented Nov 25, 2015

http://tc39.github.io/ecma262/#sec-array.prototype.slice

NOTE 2 The explicit setting of the length property of the result Array in step 11 is necessary to ensure that its value is correct in situations where the trailing elements of the result Array are not present.

The explicit setting of length is a new change vs ES5. V8 implements it, and I don't see a downside from an implementation standpoint. But I don't understand what this note means. If this happens to be creating an %Array%, then doesn't ArraySpeciesCreate already start it out at the right final length, so the trailing holes will be present already?

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Nov 25, 2015

Contributor

The explicit Set() was erroneously removed in ES5, it is present in ES3 (ES3, 15.4.4.10 Array.prototype.slice, step 19): https://bugs.ecmascript.org/show_bug.cgi?id=417

Contributor

anba commented Nov 25, 2015

The explicit Set() was erroneously removed in ES5, it is present in ES3 (ES3, 15.4.4.10 Array.prototype.slice, step 19): https://bugs.ecmascript.org/show_bug.cgi?id=417

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Nov 25, 2015

Member

I can see how that's needed in ES5, since it constructs an empty array. However, in ES2015, we start with ArraySpeciesCreate of the appropriate length.

Member

littledan commented Nov 25, 2015

I can see how that's needed in ES5, since it constructs an empty array. However, in ES2015, we start with ArraySpeciesCreate of the appropriate length.

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Nov 25, 2015

Contributor

I just wanted to provide the history behind the Set() call, I don't think I care whether or not it's present. But if it gets removed from Array.prototype.slice, it should also get removed from Array.prototype.splice (Set(A, "length", actualDeleteCount, true)).

Contributor

anba commented Nov 25, 2015

I just wanted to provide the history behind the Set() call, I don't think I care whether or not it's present. But if it gets removed from Array.prototype.slice, it should also get removed from Array.prototype.splice (Set(A, "length", actualDeleteCount, true)).

@bterlson bterlson added the question label Dec 1, 2015

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Dec 1, 2015

Member

Leaving aside the issue of whether the set to length is still required (which we can consider if someone wants to seriously propose that), the note is confusing in light of ES2015 semantics. I will fix it presently.

Member

bterlson commented Dec 1, 2015

Leaving aside the issue of whether the set to length is still required (which we can consider if someone wants to seriously propose that), the note is confusing in light of ES2015 semantics. I will fix it presently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment