Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A cleaner, faster way to implement this sort of thing is to use the "labels as values" extension if using GCC or Clang []. It avoids the switch statement and associated comparisons. Particularly useful if you're yielding inside nested loops (which IMHO is one of the most useful applications of coroutines) or switch statements.

[] https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: