|
|
|
|
|
by BiteCode_dev
2220 days ago
|
|
Yes but this require the entire runtime to be designed that way from the start. It cannot be applied to legacy languages. Just like you could not add a borrow checker to C without creating 2 worlds in the C community. But you can design Rust with this in mind. A design always has a context. Also, make a giant coroutine has a performance price, because any line is a potiential context switching. |
|
The reason you wouldn't do it in C is that there are so many implementations and only a couple of them will actually update. In most languages the extra difficulty for retrofitting it would probably be less than the difficulty of designing and implementing it in the first place.
> Also, make a giant coroutine has a performance price, because any line is a potiential context switching.
A notable one? You need a stack anyway, and you don't really have to change anything to make it switchable.
You have to avoid taking a mutex and then calling into arbitrary code, but that was already a terrible idea.