Steve Yegge's rant on The Next Big Language
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Tue Feb 13 16:03:52 PST 2007
BCS wrote:
> Reply to Jarrett,
>
>> Generators, on the other hand, are just plain cool. I think they can
>> be done using something like StackThreads.
>
> I'm missing somthing here: what is a generator?
A generator is like a function, but after it "returns" it can be
"called" again and it will resume where it left off. Local variables are
preserved, and execution resumes after the statement that caused the return.
They're basically an automated method for creating an iterator object
out of an opApply-like function.
In Python, you create them by using 'yield' instead of return.
Python tutorial section on generators:
http://docs.python.org/tut/node11.html#SECTION00111000000000000000000
More information about the Digitalmars-d-announce
mailing list