-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Normative: re-use IteratorResult objects in some iterator helpers #3489
base: main
Are you sure you want to change the base?
Conversation
62486f2
to
fde82f1
Compare
Why do you consider this to only be bad for the .value getter and not for the .done getter, which would be double-triggered by all those methods? |
I think an expensive value getter is more likely than an expensive done getter. |
@nicolo-ribaudo Also, someone might be surprised that the resulting iterator yields values for which the predicate would return edit: I've added a slide to the upcoming presentation covering interactions with getters. |
@anba Do you have an opinion on this change? |
This change is possibly difficult to implement for JSC and SM, because both use self-hosted JS for their implementation and the proposed changes can't be easily implemented in JS. ( I guess this also applies to tc39/proposal-iterator-sequencing#18. |
Do you mean that they can't be easily implemented in JS at all, or do you mean using generators in JS? It seems manual iteration in JS should work fine.
I'm open to also requiring the final |
This re-uses IteratorResult objects when it's possible to just pass the object through. There are currently 3 cases of this:
take
/drop
/filter
. See related PR for the iterator sequencing proposal, which also has this opportunity: tc39/proposal-iterator-sequencing#18I actually don't like doing this for
filter
sincefilter
observes the value, which would mean triggering a value getter both for filtering and by the eventual consumer.