Content deleted Content added
Nowhere man (talk | contribs) |
|||
Line 213:
: First of all, [[Generator (computer science)|generators]] and [[iterator]]s do have separate articles, specifically because they are not the same thing. However the external behavior of generators does share a lot in common with that of iterators, so it is worth discussing on this article. Note also that the C++/STL concept of an iterator is much richer and more specialized that the general concept of iterator; so the difference between the two will appear much more pronounced if you have a C++ perspective. It may make it easier to realize that a generator ''is'' basically an iterator over a collection; it's just that the ''collection'' happens to be algorithmically defined rather than having to physically exist in a memory-resident data structure. Also generators in as much as they act like iterators only support the most fundamental behavior; referencing the current element and getting to the next one (although the ''next'' function is implicit); it by no means acts like many rich C++-style iterators with all their additional behaviors. -- [[User:Dmeranda|Dmeranda]] 16:25, 24 April 2007 (UTC)
::OK, generators and iterators do have similarities, but the following text has no justification: "''Generators are usually invoked inside loops. The first time that a generator invocation is reached in a loop, an iterator object is created that encapsulates the state of the generator routine at its beginning, with arguments bound to the corresponding parameters.''" Where does that come from? I never saw an iterator created when using a generator, be it in C++ or nay other language I use.
::There are a lot of generators that are not meant to be used in loops, like random or prime numbers generators.
::Also, generators' purpose is not to control loops. They are not to be mistaken as some sort of functional control structure! [[User:Nowhere man|Nowhere man]] 18:50, 24 April 2007 (UTC)
|