3 ms·
This is pretty great. In the past I've had some awful things to say about generators as compared to more powerful control flow primitives, but this transformat
by anonymoushn 13y ago
This is pretty great. In the past I've had some awful things to say about generators as compared to more powerful control flow primitives, but this transformation highlights an advantage of generators. The transformed code is tiny and surprisingly readable. If someone wanted coroutines that could yield from subroutines, or (heaven forbid) shift+reset, this sort of transformation of basic-blocks-and-gotos into loops-and-cases would no longer be sufficient. Generators hit a sort of sweet spot.
Thanks :)
- bnjmn 13y agoReally agree with this. I've come to appreciate both the limitations and power of generators during the course of this project.