Uh oh!
There was an error while loading. Please reload this page.
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.
rust-highfive
commented
Jun 18, 2016
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
Stebalien
commented
Jun 18, 2016
Related to #32999 and rust-lang/rfcs#1581. |
steveklabnik
commented
Jun 19, 2016
I find "fusedness" to be a bit confusing here. |
tbu-
commented
Jun 19, 2016
It's only in the commit description. I don't know a proper word for it. |
steveklabnik
commented
Jun 19, 2016
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. |
tbu-
commented
Jun 19, 2016
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. |
alexcrichton
commented
Jun 19, 2016
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. |
aturon
commented
Jun 21, 2016
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. |
tbu-
commented
Jun 21, 2016
@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 |
aturon
commented
Jun 21, 2016
@tbu- I don't mean refactoring in What do you think about the idea of making |
tbu-
commented
Jun 22, 2016
@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 |
steveklabnik
commented
Jun 27, 2016
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:
|
alexcrichton
commented
Jun 28, 2016
The libs team discussed this yesterday and @aturon will comment more to the conclusions (placing something in his inbox via this comment) |
bors
commented
Jul 19, 2016
☔ 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.