In the past we have explicitly attempted to drop as many suffixes as
possible (see #8090). This is a little bit of a tricky topic, and to
me it depends on how you name the iterator. To me, iter::Map and
container::Map are clearly different if they are named that way. If
they are imported and then named via Map, then I can see how there
would be some confusion. I have a preference to naming things through
a module instead of importing giant numbers of capital-letter things
at the top of a file.

We already have an open issue about reorganizing libstd (#9208) with a
major goal of reducing stuttering all over the place (which adding
Iterator suffixes would add in a few places).

Mostly just food for thought.

On Fri, Dec 20, 2013 at 8:51 PM, Palmer Cox <[email protected]> wrote:
> 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
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to