SDF Chatter

4,745 readers
184 users here now
founded 2 years ago
ADMINS
SDF
1
3
Coroutines for Go (research.swtch.com)
 
 

Why we need coroutines for Go, and what they might look like.

Another great post from Russ Cox, in his series on iterators and coroutines.

https://research.swtch.com/coro

2
 
 

This post is about why we need a coroutine package for Go, and what it would look like. But first, what are coroutines?

Every programmer today is familiar with function calls (subroutines): F calls G, which stops F and runs G. G does its work, potentially calling and waiting for other functions, and eventually returns. When G returns, G is gone and F continues running. In this pattern, only one function is running at a time, while its callers wait, all the way up the call stack.

3
4
1
Coroutines for Go (research.swtch.com)
 
 

There is a discussion on Hacker News, but feel free to comment here as well.

5
 
 

[ comments | sourced from HackerNews ]

6
 
 

Go tech lead Russ Cox:

This post is about why we need a coroutine package for Go, and what it would look like.

With a post like this it usually means there will almost certainly be a new standard library package. But even more interestingly:

If we are to add coroutines to Go, we should aim to do it without language changes. That means the definition of coroutines should be possible to implement and understand in terms of ordinary Go code. Later, I will argue for an optimized implementation provided directly by the runtime, but that implementation should be indistinguishable from the pure Go definition.

view more: next ›