3 ms·
The index of a variable functions as an iterator for the iterator pattern. It still applies. There's not distinction here. But my point is also more general it
by neonological 6y ago
The index of a variable functions as an iterator for the iterator pattern. It still applies. There's not distinction here. But my point is also more general it doesn't apply to just iterators.
- xapata 6y agoScope matters. The purpose of the iterator is to encapsulate the state. An induction variable is not an iterator. A physical loop of tape is not an iterator. I'm starting to doubt your general point, because the specific isn't holding. Take a look at the Wikipedia page for iterators, under the heading "contrasting with indexing". It's not explained super-well, but it covers a few topics.
- neonological 6y ago>I'm starting to doubt your general point, because the specific isn't holding. A Very unwise and illogical notion to hold. We're addressing a very informal corner of CS that could be ripe with exceptions. Additionally the English language itself is full of grammatical inconsistencies so a single thing not holding does not disprove a generality. >Take a look at the Wikipedia page for iterators, under the heading "contrasting with indexing". It's not explained super-well, but it covers a few topics There's a contrast but nothing says this encapsulated state can't be an index itself. Meaning you can use indexes to implement iterators. As for the other point. The distinction between iterator and iteration. I still don't see it other than the fact that an iterator is used for iteration. From this page: https://en.wikipedia.org/wiki/Iteration https://en.wikipedia.org/wiki/Iteration "In Object-oriented programming, an iterator is an object that ensures iteration is executed in the same way for a range of different data structures, saving time and effort in later coding attempts. In particular, an iterator allows one to repeat the same kind of operation at each node of such a data structure, often in some pre-defined order. " Either way this is really an argument on semantics for a very narrow topic. The context is greater in scope and is about design patterns in general which I'm sure you'll agree doesn't encounter controversial collisions in meaning like iterator vs. iteration.