Talk:Generator (computer programming): Difference between revisions

Content deleted Content added
Line 212:
[[User:Nowhere man|Nowhere man]] 09:53, 24 April 2007 (UTC)
 
: 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 fundamentalAllfundamental 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.
Line 241:
[[User:Dmeranda|Dmeranda]] 19:52, 24 April 2007 (UTC)
::::This article should not, as it is named, be about a specific subtype of generators, namely iterator-like generators. If you want to described them, and there is obviosuly much to say about them, then, fine, go ahead, but in a specific article. The article about generators in CS should about generators in CS. So what about refactoring this article in a general one (that I'm willing to write) and a specific one about iterator-like generators and their variants like list comprehensions? [[User:Nowhere man|Nowhere man]] 20:25, 24 April 2007 (UTC)
 
:Although I understand there is confusion that needs rectified, I disagree that this article's topic is too narrow in definition. [[Generator (computer science)]] generally agrees with most of the computer science literature in it's use of that term, as an iterator-like function. I've not seen any comp sci literature which defines what a ''generator'' (unqualified) is otherwise, except for the apparent convention of using the word in specific instances such as ''random number generator'', ''code generator'', ''name generator'', ''character generator'', etc. that are just a consequence of the common English meaning of the word, rather than a non-English teachnical meaning specific to the comp sci community. Many of those specific uses are listed on [[Generator (disambiguation)]] (although the disambig page seems to have been renamed to just [[Generator]] now). Would it suffice to just make a more verbose disambiguation statement at the top of the article, maybe something like:
:: ''This article is about a type of function in computer science that behaves like an iterator. For other uses of the term in computing in general see [[Generator]].''
:Would that work? We could of course try to invent a broader-scoped definition, but I'm hesitant to do so. -- [[User:Dmeranda|Dmeranda]] 21:39, 24 April 2007 (UTC)