Generators and the Sweet Syntactic Sugar of Coroutines--Adi Shavit

Save to:
Instapaper Pocket Readability

A very detailed and interesting article, a must read!

Generators and the Sweet Syntactic Sugar of Coroutines

by Adi Shavit

From the article:

“Coroutines make it trivial to define your own ranges.”
— Eric Niebler, Lead author of the C++ Ranges proposal (edited for drama)

Hmmm… is that so?
But wait, what are coroutines?

From Boost.Coroutine2: A coroutine (coined by Melvin Conway in 1958!) is a function that can suspend execution to be resumed later. It allows suspending and resuming execution at certain locations and preserves the local state of execution and allows re-entering the subroutine more than once. In contrast to threads, which are pre-emptive, coroutine switches are cooperative: the programmer controls when a switch will happen. The kernel is not involved in the coroutine switches.

This sounds just like what we want!

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.