-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Annotate all core iterators with their fusedness #34343
Conversation
For almost all of these iterators the fusedness is straightforward and unlikely to change (e.g. making a memory-safe slice iterator that is not fused is actually a hard thing), but there is exactly one exception: `Chain`. The extension to make it fused is trivial and shouldn't have any performance implications.
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
Related to #32999 and rust-lang/rfcs#1581. |
I find "fusedness" to be a bit confusing here. |
It's only in the commit description. I don't know a proper word for it. |
Even in the text, "this iterator is fused." We don't talk about what "fused" means anywhere in the docs that I'm aware of. |
Ah, you mean the word in general. The motivation for this word was the I'm not particularly attached to this naming. :) It seems at least two people came up with it independently, I haven't seen @Stebalien's RFC and pull request before. |
We may want to be careful when doing this as it could possibly put us in an uncomfortable position in the future if we were to want to not have an iterator be fused for something like performance reasons. I feel like docs like this have come up in the past and I forget what we decided. Historically though we may have always qualified this with "The current implementation (not guaranteed) ...", but that seems not too useful. |
I went through each of the iterators, and except for the case noted (
etc. |
I have mixed feelings about this change -- in general, I feel like code using iterators should be robust against non-fused iterators, because of the potential for refactorings that change the underlying iterator to a non-fused one. How common is it to write code that relies on fusedness anyway? I could imagine instead recommending using explicit fusedness when you need to rely on it -- and then using specialization to ensure that there's no performance penalty on already-fused iterators. That would then make this all a true implementation detail, and provide a more explicit way to state the guarantees you want to rely on. |
@aturon If the only concern is refactoring, then please look at the iterators. These are all simple iterators in the Just take the slice iterator for example: Can you give me any way to turn it into a non-fused iterator? Fusedness is important for some stuff, e.g. the |
@tbu- I don't mean refactoring in What do you think about the idea of making |
@aturon I like that, we should definitely do that. However, I don't think we can nudge people in the direction of using
For these reasons, I think it'd be useful to make the guarantees we can make, that people will rely on anyway, and which we won't change anyway. |
I agree that the jargon 'fused' is hard to interpret. Can the word be hyperlinked somewhere useful? Alex also suggested just expanding what 'fused' means, like "once this iterator returns |
Maybe the term should be on the std::iter page, which can then be linked? On Jun 27, 2016, 17:48 -0400, Brian Andersonnotifications@github.com, wrote:
|
The libs team discussed this yesterday and @aturon will comment more to the conclusions (placing something in his inbox via this comment) |
☔ The latest upstream changes (presumably #34898) made this pull request unmergeable. Please resolve the merge conflicts. |
For almost all of these iterators the fusedness is straightforward and
unlikely to change (e.g. making a memory-safe slice iterator that is not
fused is actually a hard thing), but there is exactly one exception:
Chain
. The extension to make it fused is trivial and shouldn't haveany performance implications.