Questions tagged [generators]
For questions relating to generators, an iterable-like construct that allows for a lazily evaluated sequence of values generated by a generating function.
6 questions
8
votes
1
answer
562
views
How are coroutines implemented in a tree-walking interpreter?
It seems to me that coroutines and derived abstractions like the iterators and generators are implemented the following way:
When returning
Move the function's stack frame to the heap
Save a pointer ...
20
votes
5
answers
6k
views
Why do so few languages have this type of coroutine feature?
I used to code a lot in a language called Supercollider, which is a domain-specific language for sound synthesis and computer music.
One really nice feature it has is coroutines. Python also has these ...
6
votes
1
answer
204
views
How continuations compiles generators and coroutines?
Motivation
I have seen many places saying that CPST (continuation-passing style transformation) can express all control flows, but the examples they give are relatively simple and do not involve any ...
10
votes
1
answer
357
views
How are generators implemented?
Several languages, such as JavaScript, C#, and Python, have "generator" methods that lazily yield a series of values rather than returning a single one:
...
1
vote
2
answers
233
views
What are the pros and cons of having a unique type for generators?
For languages that allow generators (iterables where elements are determined by a function), what are the pros and cons of having a unique type for generators?
For example, languages like python have ...
5
votes
3
answers
219
views
What are some syntax options for generators?
Some programming languages allow you to create generators - lazily evaluated iterable objects that use a function to determine what the next item should be.
For example, Python allows:
...