Re:Ask HN: What is the future of programming languages?
by kedean on Friday March 01, 2013 @11:33PM
(#5308472)
Pythons generators are similar to that idea, although it's not their official use. Using 'yield' instead of 'return' in python lets you return to that function at the same point of execution later on (using .next()), at which time you could have changed member variables of the class wrapping that function, effectively modifying the environment of the function, yet the local variables are exactly as they were and so execution still proceeds as it should.
Normally this is used for producing very large lists in an on-demand manner, rather than precomputing, but it can be abused for some very unique things.
Normally this is used for producing very large lists in an on-demand manner, rather than precomputing, but it can be abused for some very unique things.