←back to thread

218 points signa11 | 1 comments | | HN request time: 0s | source
Show context
throwaway7894 ◴[] No.43681154[source]

  #define hc_task_yield(task)   
  do {     
    task->state = __LINE__;   
    return;     
    case __LINE__:;           
  } while (0) 

That's just diabolical. I would not have thought to write "case __LINE__". In the case of a macro, using __LINE__ twice expands to the same value where the macro is used, even if the macro has newlines. It makes sense, but TIL.
replies(5): >>43681327 #>>43681410 #>>43681515 #>>43681600 #>>43684691 #
veltas ◴[] No.43681327[source]
Credit to Simon Tatham

https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html

replies(2): >>43686337 #>>43703289 #
1. quietbritishjim ◴[] No.43703289[source]
> no commonly used high level language supports the coroutine call primitive

Shows how old this post is. In fact I remember reading it well over 10 years ago, maybe more like 20. archive.org says that it's at least as old as 2001. A great article.

I'm very excited to see he's published a new article on C++20 coroutines. I've read (or maybe skimmed...) a few introductions and not really got them, despite having used C# and Python coroutines a lot with no problems (even making changes to an async runtime for Python). Given how clear his C coroutine article is, I'm optimistic about the C++ article.

> So, after the course, I went away and studied on my own, and wrote the introduction to C++ coroutines that I’d have liked to see.

https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/corou...