I noticed recently that there seem to be 3 distinct Iterator naming
conventions currently in use:

1. Use the "Iterator" suffix. Examples of this are SplitIterator and
DoubleEndedIterator.
2. Use the "Iter" suffix. Examples of this are ChunkIter and ComponentIter.
3. Use no particular suffix. Examples of this are Invert and Union.

Iterators are somewhat special objects, so, it makes sense to me that they
have a suffix in common to denote their common behavior. It seems
non-ideal, however, that there appear to be 3 separate conventions in use
since that is just confusing. Personally, I think I prefer #1 because its
far and away the most common and and because I think #2 and #3 have issues:

#2 ("Iter" suffix): If we used this suffix, would we rename
DoubleEndedIterator to DoubleEndedIter? That looks awkward since we
abbreviated Iterator without abbreviating anything else. However,
DblEndedIter is a monstrosity. So, this convention seems non-ideal to me.

#3 (no suffix): I think its pretty confusing while reading through code
that there are both iter::Map and container::Map since they are completely
unrelated. I'm also not a big fan of Union since I think as a union as a
collection of information that I can iterate multiple times. However, since
Union is itself an Iterator, I can only iterate it once. This means I would
have to be careful passing a Union around to make sure I don't pass around
an already iterated Union object.

So, I opened up https://github.com/mozilla/rust/pull/11001 to standardize
on #1 - all Iterators have an Iterator suffix.

Thoughts?

-Palmer Cox
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to