Skip to content
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

Using %Array.prototype.values% #29

Closed
js-choi opened this issue Jul 20, 2022 · 1 comment · Fixed by #30
Closed

Using %Array.prototype.values% #29

js-choi opened this issue Jul 20, 2022 · 1 comment · Fixed by #30
Labels
question Further information is requested

Comments

@js-choi
Copy link
Collaborator

js-choi commented Jul 20, 2022

Right now, the proposed algorithm uses %Array.prototype.values%, CreateArrayIterator, and %ArrayIteratorPrototype%. This is a shortcut for the machinery that handles non-iterable array-like objects, like Array.prototype.values does. @ljharb pointed out in #14 (comment) that we could eventually apply this simplification to Array.from as well.

However, @bakkot pointed out a potential problem on Matrix:

Array.prototype.values produces an iterator which uses the current value of %ArrayIteratorPrototype%.next, which is not what Array.from does[,] so it's not a totally straightforward refactoring

This may also be a problem for Array.fromAsync. We need to closely examine whether we can refactor Array.from and Array.fromAsync to use %Array.prototype.values% without any observable difference. The intent has always been to make sure that Array.fromAsync follows Array.from in its treatment of non-iterable array-like objects.

If we are not able to do this soon (before @nicolo-ribaudo and @ljharb perform their Stage-3 reviews again, with the goal being the 2022-09 plenary), then we may have to switch this proposal’s specification not to use %Array.prototype.values% and to defer refactoring to use %Array.prototype.values% later, after this proposal is accepted for Stage 4. See also #23.

@js-choi js-choi added the question Further information is requested label Jul 20, 2022
@ljharb
Copy link
Member

ljharb commented Jul 20, 2022

Given that problem, which had not occurred to me, it'd indeed probably be simpler for now to remove the values simplification in this proposal.

js-choi added a commit that referenced this issue Jul 20, 2022
Removes use of %Array.prototype.values%.
Closes #29.
Maybe in the future we can come back to this and simplify both Array.from and Array.fromAsync with %Array.prototype.values%. Because we haven’t confirmed that this is truly unobservable, today is not that day.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants