Remix.run Logo
lelanthran 4 hours ago

> Hmm. I'm fairly certain that most of that assembly code for saving/restoring registers can be replaced with setjmp/longjmp, and only control transfer itself would require actual assembly.

Actually you don't even need setjmp/longjmp. I've used a library (embedded environment) called protothreads (plain C) that abused the preprocessor to implement stackful coroutines.

(Defined a macro that used the __LINE__ macro coupled with another macro that used a switch statement to ensure that calling the function again made it resume from where the last YIELD macro was encountered)

Cloudef 3 hours ago | parent [-]

Wouldnt that be stackless (shared stack)

lelanthran 3 hours ago | parent [-]

Correct; stackless. I misspoke.