←back to thread

218 points signa11 | 2 comments | | HN request time: 0.001s | 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. makeset ◴[] No.43686337[source]
I knew the name sounded familiar:

Simon Tatham's Portable Puzzle Collection https://www.chiark.greenend.org.uk/~sgtatham/puzzles/

replies(1): >>43702650 #
2. dwattttt ◴[] No.43702650[source]
Also author of PuTTy